Friday, December 14, 2012

How to set a crontab job for a perl script

In this tutorial I’m going describe how to set a crontab job for perl script on a linux system. The following example I'm going to demonstrate, how to  execute perl script every five minutes. below is the steps

[1] list the existing crontab using following command. If you have not set any crontab jobs it will display noting.
[shehan@localhost ~]$ crontab -l

crontab job

[2] issue following command to create a new crontab or edit previously created crontab 
[shehan@localhost ~]$ crontab -e

[3] add following line of code to crontab and don't forget to edit your perl script path.
*/5 means script will be executed every 5 minutes time , for ex :- 10.00 , 10.05 , 10.10 etc

*/5 * * * * perl /path/to/your/perlscript/

some tricky example
3-58/5 * * * * perl /path/to/your/perlscript/

This would still execute perl script every five minutes, but it would run on the 3's and 8's - e.g. 12:03, 12:08, 12:13, 12:18, etc.

[4]that's it !


No comments:

Post a Comment

Related Posts