Cron – Log When Job Ends?

Home » CentOS » Cron – Log When Job Ends?
CentOS 3 Comments

Hello,

In trying to resolve a problem with a cron job, we can see when the job starts by looking in the /var/log/cron log file. However, I was asked if when the job ends could also be logged. (It seems to be something that crops up every so often over the years.)

I found on the ‘net this article https://serverfault.com/questions/248915/crontab-is-there-any-log-with-begin-and-end-time

which mentions a loglevel (-L) option, and by setting this to 2 it will log when a cron job ends. It sounds great, and just what we could use. The downside is that there seems to be no such option anymore. The article is several years old but the users says they are using anacron. Checking on both a CentOS 7 and Fedora 31 system, which both use cronie-anacron, I could find no mention of any loglevel.

Does anyone know what happened to this option (why it was removed)? It would seem to be useful, but removed at some time.

Thanks,

John.

3 thoughts on - Cron – Log When Job Ends?

  • Hallo, I think the right way is to add logging into the script with all details for debug and and monitoring. Ralf

    Von meinem iPhone gesendet

  • 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.

  • For what it’s worth, you’ll see entries in the journal for slices starting and ending when the job starts and stops.