Saturday, July 12, 2008

How to make a cron job

Cronjobs can be declared using default crontab editor

EDITOR=vi
This will first set the default editor to vi

and then execute
crontab -e
this will open the default crontab editor.

You can now add few lines to it that will be your cron jobs
20 04 * * * /mnt/users/ajaved/test.sh >> /mnt/users/ajaved/test.log 2>&1

This will basically be executing test.sh each 04:20 AM on each day each week and each month, and writes the ouput to a file called test.log present in the same directory. It also appends the error to the same file if any.

Sphere: Related Content

0 comments: