Define Cron tasks

Today I need to define a couple of Cron tasks. In this post, I will write down my experience.

Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax)
Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command Any command to be executed.

http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

1. Execute a script in every 15mins,

# every 15mins -xxx check
*/15 * * * * cd /xxxx/xxx_checker ; ./xxx_checker.pl

2. Execute a script in 9:30AM and 5:30PM in every working day,

# every 9:30AM and 5:30PM - xxx check
30 9,17 * * 1-5 cd /xxxx/xxx_checker ; ./xxx_checker.pl

3. Execute a script in every min,

# every min - xxx check
* * * * *  cd /xxxx/xxx_checker ; ./xxx_checker.pl

Use below command to list all of the cron jobs running backgroupd.

crontab -l

Use below command to remove all of the cron jobs running backgroupd.

crontab -r

Use below command to start the cron jobs defined in the cron.txt

crontab cron.txt