Thursday, July 5, 2012

How to use crontabs in Linux

How to create a crontab

Open your terminal and run:

crontab -e
This will be for your user. 

Usually this should open up your crontab file in nano. Today, we will run our crontab to execute hourly:
0 * * * * /bin/sh /PATH/TO/SCRIPT
Now, this runs hourly shell scripts(/bin/sh).

 If you would like to run other scripts, obviously you simply change the "/bin/sh" to whatever you would like(python, perl, bash, etc...).

minute 0-59
hour 0-23
day 1-31
month 1-12
day-of-week 0-7 (0/7 Sunday, 1 = Monday, 2 = Tuesday, etc...)
command-line the command to execute

No comments:

Post a Comment

Please make suggestions :)