I know that cron events are stored in /var/log/syslog
and I can use a command like:
sudo cat /var/log/syslog | grep cron
to see them.
I'd much rather have the system keep a separate cron log file so it doesn't do as much work watching it, as it sorts through all the syslog
messages to pull out the cron
notifications.
Then I want to use the watch
command so I always have an open terminal window showing cron activity.
How do I make the system keep a separate /var/log/cron.log
file?
Here is the simplest way to do it:
--> Make a change in
/etc/rsyslog.d/50-default.conf
with your favorite editor:Use Ctrl-f (find) and type
cron
to find the line that saysRemove the
#
from that line. Then restart the service:From then on, all cron-related output will go to
/var/log/cron.log
In order to prevent
cron
from sending summary emails, place this line at the beginning of yourcrontab
file:Then to watch it in near-real-time, first create a
wcron
command:Whenever you want to monitor
cron
in near-real-time in a terminal window, enter:This is handy to have open in one of the 4 virtual desktops, perhaps along with System Monitor.
If you want to see more than just the launch times of longer jobs, it is easy to make the cron.log show both script start times and script end times, along with non-zero exit status messages.
How to change cron log level?
PARAPHRASED EXCERPT:
To add the
-L 15
option, open the editor by using:OR I RECOMMEND:
and replace the line
with
Then reload the configuration:
It will load it on boot also.
This enables
wcron
to show all the information you need to watch your cron system as it runs your scripts on schedule.One final idea for monitoring
cron
is to teach your scripts to speak.16.04 LTS How to make the system announce the time at the top of the hour with eSpeak
I have many of my scripts announce when they start and when they stop, or if they encounter errors.
Volume may be adjusted in the
espeak
command so they can be subtle.