Cron Job that runs php script every hour


I need help setting up a cron job on a server. The purpose of the cron job is to run a php script every hour. The script deletes the contents of some tables in a mySQL database.

I have tried to use the following (from this tutorial):

curl -s -o /dev/null

Even though the script runs nicely if I run it from a browser manually, the cron job doesn't run the script.

I have another cron job that works:

php -f /var/www/ -- reindexall >/dev/null 2>&1

I don't have access to the cPanel, so I have to tell my web hosting company to set up the job on the server.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Look into the following when running a crontab job:

1- set the env. variables for the script to run
2- use full pathnames to files and dirrctories
3- redirect output and errors to files that you can check later.
4- specify the shell to use to run the script with.

Do you get any errors while running the crontab job?
webdesigner_dkAuthor Commented:
Thanks for the answer. I get this in the log:

Sep 11 18:05:01 prod9 /USR/SBIN/CRON[18161]: (root) CMD (curl -s -o /dev/null

Any ideas?
I think this means the job was run at that time

but did you try to put the command in a shell script with setting env. variables etc?
webdesigner_dkAuthor Commented:
My web hosting company managed to solve the problem. Thanks for your answers.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
webdesigner_dkAuthor Commented:
My web hosting company managed to solve the problem. They didn't give any details though.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.