0

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?

0

Make a change in /etc/rsyslog.conf with your favorite editor:

sudo vi /etc/rsyslog/50-default.conf

Find the line that says

#cron.*         /var/log/cron.log

Remove the # from that line. Then restart the service:

sudo service rsyslog restart

From then on, all cron-related output will go to /etc/log/cron.log


Then to watch it in a terminal window,

create a wcron command script:

echo "#!/bin/bash" >wcron
echo "watch -n 120 tail -n25 /etc/log/cron" >>wcron
chmod +x wcron
sudo cp wcron /usr/sbin

From then on, whenever you want to monitor cron in real-time, enter:

wcron

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.