crontab in Linux

crontab is used to run scheduled tasks like get backup of your project frequently, clear temp file frequently,etc... If you have some scheduled tasks to be executed automatically, crontab is the best place to fulfil your requirement.

Use Following command to see scheduled crontab list.
crontab -l

Use following command to add/delete crontab processes
crontab -e 

use Following Command to stop/start/status/restart crontab prosesses.
/etc/init.d/crontab start
/etc/init.d/crontab stop
/etc/init.d/crontab status
/etc/init.d/crontab restart


min         hour         day_of_month      month          day_of_week        Process
(0-59)      (0-24)             (1-31)             (1-12)                 (0-6)              process
                                                             (jan-dec)

Examples:
To run cd /home/etutionlk command in every minute. Add following crontab statement.
*/1 * * * * cd /home/etutionlk
Run test.sh file in every hour
* */1 * * * sh test.sh
Run xmas_greeting.sh file in 25th of December in every year at 8.00 am
0 8 25 12 * sh xmas_greeting.sh
Have a Nice Experience with crontab !


0 comments:

Post a Comment

Ask anything about this Tutorial.