View Full Version : crontab and php

18th November 2004, 05:37 PM
Hello guys,

I have a couple question that i'm stuck with. First i created a script to back up all my databases using php. Now I want to have it run using cron at midnight every day. So this is what i placed in the crontab file

0 0 * * * /root/scripts/backupDBs

Now, i read some of the posts and the some of the man pages and that seems to be right. Now, i did this last night and to my surprise it didn't run. Any ideas as to why? on the crontab file there are other lines:

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

not really sure what run-parts mean, i'm assuming that root is the user thats going to be running this script as...

Should i include a user in the line that i inserted? how about run-parts?

I can run the script by typing:


and it works fine. And that brings me to my second question... when i run this command i get a

[root@sys1 scripts]# ./backupDBs
Content-type: text/html
X-Powered-By: PHP/4.3.8

does anybody know how to get rid of this? I know i can use php -q scriptName but that means i need to run the php command... if i don't want to run it that way then it's going to come up.

Any ideas?

Thanks :cool:

18th November 2004, 06:23 PM
I assume that crond is running????

18th November 2004, 06:26 PM
yes crond is running

18th November 2004, 07:31 PM
If youre running a php script as a crontab it should be listed as such:

* * * * * * * * * * /usr/local/bin/php /cron_script.php > /dev/null

Where /usr/local/bin/php reflects the location of PHP on your system and /cron_script.php is the location of your script.

18th November 2004, 08:34 PM
wow 10 asterisks... ok, i have this line on the php file


that should take care of the

* * * * * * * * * * /usr/local/bin/php /cron_script.php > /dev/null


Now, i know that the first asteriks are m s h d w y, but what are the other asterisks for?


18th November 2004, 09:19 PM
me being stoopid, I just normally use minute hour dayofmonth monthofyear dayofweek ( * * * * * )

(I was slacking off at work and not paying enough attention :D )

22nd November 2004, 05:18 PM
Ah... hehe it's cool. had to take a go out of town this weekend, so i couldn't work on it... but now that i'm back i'll enter it and see if it works.

thanks alyster.