Setting up an hourly cron job


#1

Hi thank you for your help.

I am trying to set up a cron job to run a script on my site every hour. This is what it looks like:
0 * * * * /usr/bin/curl -I “http://www.mywebsite.com/directory/file.php

but this does not seem to work.

Would you please let me know what I am doing wrong or any alternatives?

Thank you.


#2

Your time is set wrong. See the wiki article on crontab.
http://wiki.dreamhost.com/index.php/Crontab

–Matttail
art.googlies.net - personal website


#3

Thanks for your speedy response.

Example 4 on the page you referred me to has the same configuration for an hourly update as my code as far as the code for time is concerned.
That is: 0 * * * * for hourly updates.

Would you please let me know what you mean by “Your time is set wrong.” Thank you again for your help.


#4

maybe there’s an error…

you could take a look at /MailDir/New/ and open the recent ones in a Rich text editor (i use DreamWeaver)


#5

Sorry. Apparnetly what I ment was, I’m being stupid and not thinking clearly. Your time is set just fine.

Are you running a file that’s hosted here at dreamhost, or on some other server?

An other easy method ot get error messages back from cron to place this:
MAILTO="you@dhHostedDomain.com"
at the top of your cron file.

–Matttail
art.googlies.net - personal website


#6

Have you tried running that command manually from the command line?

And why just the -I? It’s possible this is the culprit, as it doesn’t pull down the whole file. Maybe that doesn’t matter, but I’d drop the -I and pipe the whole thing to /dev/null

0 * * * * /usr/bin/curl “http://www.mywebsite.com/directory/file.php” > /dev/null 2>&1

-Scott


#7

Thank you for all your help.
I have taken you advice on board.

Here is the process I am using.
I set up an email account: cronjob@dhHostedwebsite.com

This is what I wrote in my cronjob file

MAILTO="cronjob@dhHostedwebsite.com"
0 * * * * /usr/bin/curl -I “http://www.dhHostedwebsite.com/file.php

I saved this in notepad and called the file “a.txt”

I FTPed this file, a.txt, to the root of my DH domain.

I logged into my domain using shell

I ran the command: crontab a.txt

To check that it is running I ran the command: crontab –l which generates this:

MAILTO="cronjob@dhHostedwebsite.com"
0 * * * * /usr/bin/curl -I "http://www.dhHostedwebsite.com/file.php "[doheny]$

However the cronjob is still not running and I am not getting any error messages at cronjob@dhHostedwebsite.com

Can anyone please tell me where I am going wrong in this process?
Thank you again for all your help.


#8

Ah! Add a blank line to the end of that crontab file.

-Scott


#9

Brilliant!
Thank you all for your advice and your patience the cronjob is now running correctly.
To think it was a blank line holding me up all this time.
Argh!
I’m glad it is sorted.

Now let me go and try to sort out my .htaccess conundrum!
Thanks