Deepak Dargade

I'm a Mumbai-based Entrepreneur, Ruby on Rails monomaniac and Food enthusiast.

11 Jul 2011

Cron is a Linux system process that will execute a program at a preset time.

To use cron you must prepare a text file that describes the program that you want executed and the times that cron should execute them.

Then you use the crontab program to load the text file that describes the cron jobs into cron.

For example if we want to execute a script (.sh file) on linux server each day at a specific time, we need to use cron jobs provided by the linux server.

Steps for adding a cron job:

Step 1: To check for existing cron jobs running, open a terminal and enter

crontab -e

o/p: it will show the cron jobs for the existing user.

Step 2: The cronjob resides in the file

/etc/crontab

Step 3: edit this file to add cron job using,

nano /edit/crontab

Step 4: add the following line to the end of the file

*  *  root /var/www/hello.sh
03 05 *  * root /var/www/hello.sh

the first line runs the hello script after every 1 minute. and the second line executes the hell oscript at 03:05 am.

Step 6: make sure to restart the cron process using

restart cron


For more information on cron job format visit http://www.scrounge.org/linux/cron.html

and for Mysql Backup script, visit http://www.cloudtech.org/2010/07/30/backup-mysql-databases-automatically-on-your-vps/



Looking for comments?

I don't have comments on this site as they're difficult to manage and take up too much time. I'd rather concentrate on producing content than managing comments.

Since there are no comments, feel free to contact me ✉️ contact me instead.