On Fri, 2019-11-15 at 16:32 -0500, Karl Vogel wrote:
On Fri, Nov 15, 2019 at 05:54:07PM +0000, John Horne wrote:
J> In trying to resolve a problem with a cron job, we can see when the job J> starts by looking in the /var/log/cron log file. However, I was asked if J> when the job ends could also be logged. (It seems to be something that J> crops up every so often over the years.)
You could use something like this with your scripts. It works with ksh or bash.
Sorry, I should have been more clear. I'm not looking for a 'per-script' solution. Logging when a job starts is performed by crond, so logging when it ends should also be done by crond.
Despite the article I mentioned being from 2011, it seems that Debian 10 still supports the logging of when cron jobs end. Looking into this further it seems that Debian uses anacron, and then applies a patch which provides the '-L' option.
I have raised this with the cronie project on github to try and see why this feature has not been implemented. (It may well be that there are good reasons for it having not happened.) A very quick look at the cronie code seems to indicate it may be possible to implement.
John.
-- John Horne | Senior Operations Analyst | Technology and Information Services University of Plymouth | Drake Circus | Plymouth | Devon | PL4 8AA | UK ________________________________ [http://www.plymouth.ac.uk/images/email_footer.gif]http://www.plymouth.ac.uk/worldclass
This email and any files with it are confidential and intended solely for the use of the recipient to whom it is addressed. If you are not the intended recipient then copying, distribution or other use of the information contained is strictly prohibited and you should not rely on it. If you have received this email in error please let the sender know immediately and delete it from your system(s). Internet emails are not necessarily secure. While we take every care, University of Plymouth accepts no responsibility for viruses and it is your responsibility to scan emails and their attachments. University of Plymouth does not accept responsibility for any changes made after it was sent. Nothing in this email or its attachments constitutes an order for goods or services unless accompanied by an official order form.
On Mon, Nov 18, 2019 at 10:50:57AM +0000, John Horne wrote:
Sorry, I should have been more clear. I'm not looking for a 'per-script' solution. Logging when a job starts is performed by crond, so logging when it ends should also be done by crond.
For what it's worth, you'll see entries in the journal for slices starting and ending when the job starts and stops.