<>

cron in 2 steps

November 25, 2009

cron lets you schedule linux commands to execute on a regular basis.

For instance, say we want to run the command "wget http://yourdomain.com/backup.zip" each hour, that downloads a backup of one of your websites.

Step 1: Write the cron command

Here is the cron command you would need:

0 * * * * wget http://yourdomain.com/backup.zip

You can either memorize the crontab syntax, or just this simple Javascript crontab gui will easily generate the code for you.

Step 2: Append the command to your crontab file

There are 2 crontab files that get executed every minute. 1 of them is found in /etc or similar and is controlled by root only. In addition, each user can have a crontab.

To add your command to crontab type:

crontab -e

This will open vim, and you can then paste and save your crontab file.

Viola!

Notes

  1. If you are using cron in cygwin, follow these steps after installing the cron package with the cygwin installer to install cron as a service:
cygrunsrv -I cron -p /usr/sbin/cron -a D net start cron

If there are problems, check the cron.log file in your home directory.




Built with Scroll v161.0.0