cron time-based job scheduler

Task : How to get a Perl cgi-bin script to be ran daily, without the intervention of an administrator or webpage ever being visited.

Solution: Using the systems Cron command
I knew of cron’s existance but didnt realise how usful it was. Below is how I managed to get cron to do the job for me.

Unix commands used :

crontab -e (edit crontab using vi)
crontab -l (list your current crontab enteries)

The lines I added to my crontab :

# Location of GET
GET='/opt/lampp/bin/GET'

# Location of the script file to be ran
VLEPROCESS='http://abc.123.com/cgi-bin/happiness/ProcessFiles.pl'

# The crontab command, 59 = minutes passed the hour, 6 = Am, * = no value set, $GET value of where the GET command is, ${VLEPROCESS} wherearounds of the script to be ran.
59 6 * * * $GET ${VLEPROCESS}

So at 6:59 each morning, Monday to Sunday the script ‘ProcessFiles.pl’ gets ran.
Happy days, one less thing to remember each morning.

Further cron command option for dates and time :
.—————- minute (0 – 59)
| .————- hour (0 – 23)
| | .———- day of month (1 – 31)
| | | .——- month (1 – 12) OR jan,feb,mar,apr …
| | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s