What is CRON?
Cron is a unix/linux utlity that is used to schedule tasks that run at specific intervals. The tasks that are scheduled are called cron jobs.
What is crontab?
This is file which contains a table of scheduled jobs that drives the cron.
Multiple cron jobs can be schedule in the crontab. Ideally, each line in the file contains a cronjob information.
Crontab Commands
Crontab Syntax
Examples of crontab
Cron is a unix/linux utlity that is used to schedule tasks that run at specific intervals. The tasks that are scheduled are called cron jobs.
What is crontab?
This is file which contains a table of scheduled jobs that drives the cron.
Multiple cron jobs can be schedule in the crontab. Ideally, each line in the file contains a cronjob information.
Crontab Commands
Command | Description |
crontab -e | edit or create a crontab file |
crontab -i | list the crontab contents |
crontab -r | remove the crontab settings |
crontab -v | Last time the crontab was changed |
Crontab Syntax
Examples of crontab
Min | Hours | Day | Month | Day of week | Command | Description |
30 | 13 | * | * | * | echo 'Executes at 1:30 PM everyday' | Executes at 1:30 PM everyday |
30 | 13 | 1 | 1 | * | echo 'Executes on Jan 01 at 1:30 PM' | Executes on Jan 01 at 1:30 PM |
30 | 13 | 1 | * | * | echo 'Executes on 1st of every month at 1:30 PM' | Executes on 1st of every month at 1:30 PM |
30 | 13 | * | * | 1-5 | Executes on all weekdays(Monday-Friday) at 1:30 PM | Executes on 01 of every month at 1:30 PM |
*/5 | * | * | * | * | echo 'Executes every 5 mins' | Executes every 5 mins |
* | */5 | * | * | * | echo 'Executes every 5 hours' | Executes every 5 hours |
Restart cron in Linux
In case the timezone is changed, the CRON can be restarted using the following command
/etc/init.d/crond restart
No comments:
Post a Comment