Table of Contents

CRON

It is most important piece of command / daemon available on Linux / Unix system.
It has some nice capability which is not used but need to be aware of.

Special Usage

Following Special words replaces common conventional usage

@reboot        #Run once, at startup.
@yearly        #Run once a year, "0 0 1 1 *".
@annually      #(same as @yearly)
@monthly       #Run once a month, "0 0 1 * *".
@weekly        #Run once a week, "0 0 * * 0".
@daily         #Run once a day, "0 0 * * *".
@midnight      #(same as @daily)
@hourly        #Run once an hour, "0 * * * *".

Following variables you can define in cron as standard environment.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

Usage

Most common Usage terms defined as below. <note>when you use “*” it consider all like “* * * * *” considered as every minute of 24/7</note>

# Minute   Hour   Day of Month       Month          Day of Week        Command    
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                
    0        2          12             *               0,6           /bin/sshcheck

Also most of the time you might want to disable logging the output of commands or scripts you are running.
Which can be used as follow.

0 3 * * * bin/git_commit.sh >/dev/null 2>&1

Also some time you want to store output to file. it use standard notation for redirect.
For Append » For Overwrite >

35 0 * * * /bin/bash /home/kpatel/workspace/backup.sh >> output.txt 2>&1

Things need to know

Things need to know pasted from