How to Set up a Crontab File on Linux

Cron is a job scheduling subsystem for linux. It is used for scheduling repeating jobs. If you wish to schedule a one shot job use the at subsystem. All users on a linux box may set up cron jobs provided they are allowed by the...

Method 1 of 2:

Setting up the File

  1. Picture 1 of How to Set up a Crontab File on Linux
    Using your favourite editor, create a cron file with a line for each job you wish to schedule, in the format: m h d m w command
    1. m minute
    2. h hour
    3. d day of month
    4. m month 1-12
    5. w weekday 0-7, Sun,Mon, etc (Sunday = 0 = 7) It is easy to remember if you think of the way one would say a date: Wednesday, July 29, at 10:30, then reverse the order.
  2. Picture 2 of How to Set up a Crontab File on Linux
    Load your file into crontab: crontab yourfile
Method 2 of 2:

Trying an Example

  1. Create a file testCron.txt containing the following lines:
    1. # do this every 10 minutes
    2. */10 * * * * date >> ~/testCron.log
  2. Picture 3 of How to Set up a Crontab File on Linux
    Load it into cron: crontab testCron.txt
  3. Wait 30 minutes, check testCron.log, if it works it will update your file with a time stamp 3 times.
  4. Picture 4 of How to Set up a Crontab File on Linux
    Remove the crontab so that it does not run forever: crontab -r
Update 04 March 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile