Monday, October 11, 2010

Executing Cronjobs in Linux



Crontab Commands
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

Crontab syntax :
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

On Tuesday October the 27th at 13hours and 47minutes
Crontab syntax: 47 13 27 10 2 wget q
http://www.site.com/phpcron.php 2>&1



How to get rid of sending the output to a file? I have searched for this solkution is many forums. But never found a solution. After some trouble shooting with diffrent options I got the following command which is working!!
0 3 * * * wget -O /dev/null http://www.siite/file.php
While executing the above cronjob, the output will not be written to any log file . Instead It will just flush out to null devcie.


No comments: