Tag Archives: Cron

A little bit on Cron

What is Cron?

Cron is a service that runs periodic tasks known as cron jobs. Cron has various implementations which handle the execution of cron jobs. Cron jobs are stored in crontab file and can be edited using the crontab command.

//list all cron jobs
static-202:~ Sayeed$ crontab -l

//edit cron jobs. crontab file opens in the default text editor for editing.
static-202:~ Sayeed$ crontab -e

//set vim as the editor
static-202:~ Sayeed$ export visual=vi

//delete the crontab file of the current user. this will delete all the cron jobs.
static-202:~ Sayeed$ crontab -r

To delete a particular cron job, open the crontab file using crontab -e command -> delete the cron job -> save the file.


minute(0-59) hour(0-23) day-of-month(1-31) month(1-12) day-of-week(0-6, 0 being sunday) <command>


I wanted to add a cron job on my linux server to take the dump of MYSQL database at 00:00 hrs everyday. Here is how it looks:

0 0 * * * mysqldump -uxyz -pxyz et_prod > /home/ubuntu/et_prod.sql

More Examples

//take database dump at 10a.m. every sunday.
* 10 * * 0 mysqldump -uxyz -pxyz et_prod > /home/ubuntu/et_prod.sql

//take database dump every 2 hours.
* */2 * * * mysqldump -uxyz -pxyz et_prod > /home/ubuntu/et_prod.sql