If you're looking to troubleshoot cron jobs, the best way might be to enable logging. Jack Wallen shows you how.
Cron is a time-based job scheduler in Linux that runs system jobs and allows users to create jobs that are executed on a regular basis. Cron does simple things like regularly emptying the /tmp folder, cleaning PHP sessions, running backups, and so much more.
But the one problem with cron is that, out of the box, it doesn't have a dedicated log. This can be a problem when you're creating your own cron jobs and you need to debug them.
Without a log, you might never know if that job ran. This happened to me recently, when I created two cronjobs to keep Google Drive in sync with a local directory with rclone. I had no idea if the jobs were running, without comparing the folders. Fortunately, it's possible to enable logging with cron.
Let's find out how.
Open a terminal window on the Linux machine that houses the cron job and issue the command:
sudo nano /etc/rsyslog.d/50-default.conf
In that file, look for the line that starts with #cron.*.
Remove the # symbol and then in the second column add:
Save and close the file.
Next, restart syslog with the command:
sudo systemctl restart rsyslog
At this point, you should now see the new log file /var/log/cron.log. If you don't see it immediately, it'll appear the next time a cron job runs.
You can then read through that file with the command less /var/log/cron.log and troubleshoot any cronjobs that may or may not be running.
How to become a software engineer: A cheat sheet (TechRepublic)
10 free alternatives to Microsoft Word and Excel (TechRepublic download)
Choosing your Windows 7 exit strategy: Four options (TechRepublic Premium)
The 10 most important iPhone apps of all time (Download.com)
Must-read coverage: Programming languages and developer career resources (TechRepublic on Flipboard)