Friday, May 3, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 19836  / 1 Year ago, sat, april 1, 2023, 9:22:23

I'm concerned that cron jobs can fail silently for an indefinite period of time on vanilla Ubuntu Desktop 12.04.1 (Precise), and no one will notice. I would like to get a notification whenever a system cron job prints some output or just fails.



I know it is possible to install a mail server (e.g. postfix), configure it for local-only delivery, set up an alias so that root's mail is delivered to my normal user account and configure a mail client to check my local mailbox.



Are there any lightweight alternatives to this solution in Ubuntu?


More From » notification

 Answers
7

You could redirect the error output of your cronjob command to a file. Here is an example of a line in /etc/crontab:


01 3    * * *   user    /bin/command 2>> /var/log/some.file

Then at least you got a clue if errors occured. You might even write a script to notify you over notify-osd or similar tools when the file changes.


Edit:


The file /var/log/syslog reports messages from cron as well. You might want to take a look at that. To get a dedicated log-file for the cron deamon edit /etc/rsyslog.d/50-default.conf and uncomment/edit the line that says:


#cron.*             /var/log/cron.log

Don't know what you'll find there but worth the try. Report how it went.


[#35959] Sunday, April 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diket

Total Points: 167
Total Questions: 124
Total Answers: 109

Location: Somalia
Member since Wed, Mar 15, 2023
1 Year ago
;