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:
Go to rsyslog config

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
| improve this answer | |

When cron doesn't work, it'll send out a mail to the user root. The only problem is: you don't have the software to send / store the mail in mailboxes.

But have no fear, Postfix is here!

Install Postfix

sudo apt-get update
sudo apt-get install postfix heirloom-mailx

When install postfix, it'll ask you how to you want to setup it up. On the first screen, select local only and proceed with the defaults for everything else.

Configuring Postfix

Now, using your favorite editor, edit /etc/aliases. It'll look something like this in the beginning:

# See man 5 aliases for format
postmaster:    root

What this means is that any mail sent to postnaster will now be sent to root as well. In this case, we want any mail sent to root (for the cron mails and any other system mail) to be sent to username (us).

So, edit /etc/aliases to look like:

# See man 5 aliases for format
postmaster:    root
root:          norman

(Replace norman with your username obviously. Unless you have the same name/username as me. :) )

After that's all said and done, run the following command to push the changes:

sudo newaliases

Now, after that run:

sudo dpkg-reconfigure postfix

You'll get the same screen you had before when installing postfix. Run through the defaults (Local Only, etc..). When you get to the part when it asks for the root and postmaster alias, just make sure it's the same as the one you added to /etc/aliases above. Then, continue running through the defaults.

When you're done, run the following command to restart postfix and get underway!

sudo service postfix restart


Now, 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 No mail for <username>. Otherwise you'll get a neat terminal interface to use. See the man page for information on how to interact with your inbox.

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 cron issue.

| improve this answer | |
  • 1
    crond mails the owner of the job, not necessarily root, so if it is your own job you installed with crontab -e then you get the mail. This is also true whether or not the job "fails"... it simply emails you a transcript of any output the job had. – psusi May 17 '15 at 23:58

When running mail I got the following response:

The program 'mail' is currently not installed. To run 'mail' please ask your administrator to install the package 'mailutils'

Instead I found the errors / mails stored in /var/mail/root

| improve this answer | |

It is in /var/log/syslog by default.

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 wcron command that displays it is near-real-time. Plus, it links to another answer,

How to change cron log level?

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.