Using crontab on the Raspberry PI


Cron is described as a time-based job scheduler for the Raspberry PI and most Linux based OSes.

crontab is the tool to setup what is called a "cron job"...

crontab -e
  • The -e is to edit the current users crontab. Use -l instead to list the current jobs.
  • You could use sudo crontab -e to edit jobs for root.

The first time you use crontab it might ask you to select an editor. Just select your editor of choice. nano would be my preference on a RPI.

Add an entry at the bottom of the file similar to any one of the examples below...


The simplest; execute test.sh every minute...

* * * * * /home/pi/test.sh

Execute at every 15th minute interval. i.e 10:00, 10:15, 10:30: 10:45, and so on...

*/15 * * * * /home/pi/test.sh

Execute on the hour, every hour...

0 * * * * /home/pi/test.sh

Execute every minute on 1st May only...

* * 1 5 * /home/pi/test.sh

You can also setup a job to execute when the cron service restarts, usually at boot...

@reboot /home/pi/test.sh

Pi My Life Up's Beginners Guide to Cron Jobs and Crontab is a good guide. crontab guru is also a handy tool.


Related Articles

If your PI isn't feeling well or it just needs a health check, this is how to read its current temperature.

Raspberry PI, Linux

How to mount to a CIFS based network share from a Raspberry PI.

Raspberry PI, Linux, Networking

How to install and setup an OS on a Raspberry PI headlessly.

Raspberry PI

A quick and simple HTTP server in Python in only a few lines of code.

Raspberry PI, Python