Cron jobs

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

crontab is a powerful command in Linux. It works like at command but works even after a reboot. Because the crontab having a own service called crond, which helps to maintain the timing process after reboot.

Syntax

To edit user's crontab:

crontab -eu username

To list user's crontab:

crontab -lu username

To remove user's crontab:

crontab -ru username

Examples

Edit a file for vijay user:

crontab -eu vijay

Enter the data:

#   min   hrs   date  month  day_of_week    command
23    20     1     *       0            /bin/echo "Hello today is sunday and irst of month"

Save and close the file.

Turn on crond service=

Type the following commands under Fedora / CentOS / Redhat Enterprise Linux:

service crond start
chkconfig crond on