Where are cron logs stored on Ubuntu 14.04?
Solution 1:
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
Solution 2:
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
Conclusion
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.
Solution 3:
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