PDA

View Full Version : Cronjob not working



cosmo1983
August 18th, 2006, 02:18 AM
I have a file that is suppose to update every minute, placed it in cronjob but the file doesn't get updated every minute. It randomly updates itself right now.

Not sure if there is something wrong with the conrjob code or not.



01 * * * * php /test/somefile.php


What exactly am I doing wrong?

scxtt
August 18th, 2006, 02:22 AM
just looking at the example you've given, you're just (essentially) referencing a file (/test/somefile.php), not telling it what to do, as in:

01 * * * * php php /test/somefile.php

where php /test/somefile.php will run as the php user ...

as for it randomly updating, that's weird ...

cosmo1983
August 18th, 2006, 02:27 AM
So, I have to add two php commands before the script?
Like this?



01 * * * * php php /test/somefile.php

scxtt
August 18th, 2006, 02:30 AM
it's not 2 php commands, anacron allows you to run cronjobs from /etc/crontab (at least) as any user you want (assuming you have root access to edit it) ...


1 * * * * scxtt echo `date` >> /home/scxtt/test.txtso the 1st php in your case is designating the php user (if there is one) and the second one is saying "run php on /test/somefile.php" ...

but i've never really had luck getting crons to run per minute ...

scxtt
August 18th, 2006, 02:38 AM
looks like the format you want to use is:

0-59 * * * * php php /test/somefile.php
it's working for me in my echo `date` . . . example ... also, using vim and color syntax helps a LOT (not w/ the 0-59 thing, but in general crontab format) ...

cosmo1983
August 18th, 2006, 02:41 AM
Let me give that a shot and I am logged in as root.

cosmo1983
August 18th, 2006, 02:44 AM
Works like a charm dude. Thanks alot.

true_friend
August 21st, 2006, 09:57 AM
i want to run a script chaning my wallpaper after every 15 minutes.
what command for me???
currently trying to use
15 * * * * /usr/bin/home/ss/wallpaper/.wallpaper
plz correct mine also.

scxtt
August 21st, 2006, 10:03 AM
you should be able to get away with:

0,15,30,45 * * * * <username> /usr/bin/home/ss/wallpaper/.wallpaper

but it depends on how the wallpaper is "refreshed" ...