How to run a cron job every 5 minutes


A cron job is a task that is scheduled to run periodically on Unix-like systems. This is useful if you have a script that needs to be run every so often, such as a script to clean up a directory at the end of each day. The following instructions demonstrate how to set a cron job to execute a script every five minutes.


Use the command crontab -e to edit the crontab. This uses the editor specified in the environment variable$EDITOR, and if the variable is empty, this defaults to vi(1) or vim(1)

The format of a crontab is 6 columns, space (or tab) separated. The first 5 columns detail the time when to run a command, which is specified in the last column. The last "column" makes up all the remaining characters, inclusive of spaces. Here is an example:

5 * * * * /home/aspera/

What the above shows, per column:

  1. Minute to run on, a value of 0-59: 5 means on the 5th minute of the hour
  2. The Hour, a value of 0-23: * means every hour
  3. Day of the Month, 1-31: * means every day of the month
  4. The Month, 1-12: * means every month
  5. Day of the Week, 0-7 (0 and 7 are both Sunday): * means every day
  6. The Command: In this case, a command at/home/aspera/

With older crontabs, like the one on legacy Solaris, this is mostly all that can be done. One variation is to use comma separated lists. Modern crontabs can use string names for days, and wildcards with increments. So, to create an entry that every 5 minutes would be as follows on Linux:

*/5 * * * * /home/aspera/

The */5 notation in the first column means "every 5 minutes". To make this every 10 minutes, */10 is used. To do the same 5 minute interval on a Solaris system, try the following:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/aspera/
Powered by Zendesk