I am trying to troubleshoot why my cron task isn't working sometimes. Where does cron store log files by default? Is it /var/log/syslog ?
I have looked at that file and it is empty. Do I need to set something up?
|
|
|
As default, cron's logs saved in /var/log/syslog.
It depends on rsyslogd configuration. You can change it: cd /etc/rsyslog.d/ sudo nano 50-default.conf Uncoment line: #cron.* /var/log/cron.log Save file and restart rsyslog sudo service rsyslog restart Restart your cron daemon for get it's messages from new file sudo service cron restart |
|||
|
|
|
When But have no fear, Install Postfixsudo apt-get update sudo apt-get install postfix heirloom-mailx When install Configuring PostfixNow, using your favorite editor, edit # See man 5 aliases for format postmaster: root What this means is that any mail sent to So, edit # See man 5 aliases for format postmaster: root root: norman (Replace After that's all said and done, run the following command to sudo newaliases Now, after that run: sudo dpkg-reconfigure postfix You'll get the same screen you had before when installing When you're done, run the following command to restart sudo service postfix restart ConclusionNow, if cron has an error, it'll be mailed to you. But, you're probably wondering, how in the world do I check my (local) mail? To do that, run the command: That simple. If there's no mail it'll say Or, if you prefer, you can access your local man page by using: man mail And now, you're done! :) P.S. You should read this to learn more about the |
|||||
|
|
When running
Instead I found the errors / mails stored in |
|||
|
|
|
It is in But it can be set up to create a separate cron.log, which is more useful. This Q&A describes the process: 16.04: How do I make cron create cron.log and monitor it in real time? Also in this answer is the instructions to create a that shows how to change the log level to include more than just the start of jobs - level 15 will show errors and end time, also. |
|||
|
|