Cron is a Linux utility that schedules a command or script on your server to run automatically at a specified time and date. As the name implies a cron “job” is a scheduled job. Cron jobs can be very useful to automate almost any task in Linux.

While adding a cronjob is quite easy (just use crontab -e), but more on that in another post, getting them to work properly can sometimes be an enigma. That is why checking if your cron has run as it should is important and also quite easy.

After logging into your server and escalating to root user just type:

  1. grep “” /var/log/cron

    This will search the log files in order to display the cron results if any.

  2. If your cron has run properly, after hitting Enter you should see something similar to:
    Jun 25 05:33:02 slurpramen crond[9772]: (slurpramen) CMD (sudo xvfb-run /home/pi/python3
    Jun 25 07:33:01 slurpramen crond[16587]: (slurpramen) CMD (sudo xvfb-run /home/pi/python3
    Jun 25 09:33:01 slurpramen crond[21887]: (slurpramen) CMD (sudo xvfb-run /home/pi/python3

The output will thus show you the date, hour and what script it ran is the return is empty, you better check your cron jobs with

crontab -l

to see if they are listed.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.