How to monitor your cron log in real time:
16.04: How do I make cron create cron.log and monitor it in real time?
Excerpt:
--> Make a change in /etc/rsyslog.d/50-default.conf with your favorite editor:
sudo gedit /etc/rsyslog.d/50-default.conf
Use Ctrl-f (find) and type cron to find the line that says
#cron.* /var/log/cron.log
Remove the # from that line. Then restart the service:
service rsyslog restart
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 your crontab file:
crontab -e
(Insert first line)
MAILTO=""
Then to watch it in near-real-time, first create a wcron command:
echo "#!/bin/bash" >wcron
echo "watch -n 10 tail -n 25 /var/log/cron.log" >>wcron
chmod +x wcron
sudo cp wcron /usr/sbin
- watch -n 10 tells it to refresh the page every 10 seconds
- tail -n 25 tells it to display the last 25 entries
Whenever you want to monitor cron in near-real-time in a terminal window, enter:
wcron
------------------------------------------------------------
Same can be done to monitor syslog, by creating the slog command
echo "#!/bin/bash" >slog
echo "watch -n 2 tail -n 25 /var/log/syslog" >>slog
chmod +x slog
sudo cp slog /usr/sbin
Whenever you want to monitor /var/log/syslog in near-real-time in a terminal window, enter:
slog
Note: If you need to pause this output temporarily:
Ctrl-S for Pause
Ctrl-Q for Resume