using crontab to schedule Perl Scripts

They have: 5,633 posts

Joined: Jan 1970

This may be a little off topic. I'd written a perl script to grap stock data from site and store them into a mySQL database. I needed to run it everyday that's why I use the crontab command, and set it as follows

0 5 * * * perl stock.pl

But it doesn't work. Can someone tell me what I did wrong?

Thanks in advance.

--Ben

They have: 568 posts

Joined: Nov 1999

Your syntax is right, i'm not sure when exactly you want the script to execute but that will run every morning at 5 am.

1 Minute
2 Hour
3 Day
4 Month
5 Day of the week

So if you want to execute a command every 5 minutes you would say "5 * * * * command"

Or at least I think thats it... It's been a while since I used cron. Smiling

Thats the only advice I can give you.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I've never used cron before (never heard of it either). Just curious...

Would 0 5 * * * be 5AM everyday? or every 5 hours?

They have: 5,633 posts

Joined: Jan 1970

Max,

Crontab uses a 24 hour clock (military time). So that would be 0500 or 5am.

Benliong,

I as well don’t see anything wrong with your syntax. But haven’t setup a job in close to a year. Maybe try contacting your host and make sure they allow jobs? I know with one of my clients hosts you can set jobs up but they never run.

http://ibgwww.colorado.edu/~lessem/psyc5112/usail/automation/cron.html basically describes the essentials of using cron jobs. I had another tutorial which was illustrated but it seems to have vanished.

Hope that helps..

They have: 60 posts

Joined: Aug 2000

Be sure to use the right path to your script & if it needs any parameters, pass them in.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.