Cron trouble

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
i guess this sort of goes in programming help, if not, please just move it.

i am trying to set up a php script to run automatically each day using cron, but i can't seem to get it to work. i have it running the command:
Code:
cd /home/kbjr/cron && /usr/bin/php -q cleanPackages.php
with the time settings:
Code:
3	0	*	*	*
i don't use cron very often, so it's probably just something small and stupid, but i can't figure out what's wrong with it.

please help, and thanks in advance
 

dlukin

New Member
Messages
427
Reaction score
25
Points
0
Unless there is some reason to change to the cron directory,

Code:
/usr/local/bin/php  -q  /home/kbjr/cron/cleanPackages.php

should run the code.

Code:
3	0	*	*	*

will make it run at 12:03 AM every day.
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
ah, /usr/local/bin/php . . .
i didn't know php was in local . . .

i'll try that and see if it works, unfortunately i won't know until tomorrow morning :\
 

dlukin

New Member
Messages
427
Reaction score
25
Points
0
Depending on what it does, for testing only, you can try:

Code:
*/15	*	*	*	*

Which should run it every 15 minutes. So you will have your answer in 15 minutes.
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
that's a good idea . . . i'll try that and reply in 15 . . .
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The problem might lie with the script rather than the cron job. Does cleanPackages.php run from the browser (once you make it browser accessible)? What's the output? Any error messages?
 

fortwienix

New Member
Messages
9
Reaction score
0
Points
0
Each script that runs in a cron job must also run when you put the command directly at your console. If you don't have shell access then try to use the exec function of php.

Try to capture all output of the script. In the exec call you would do something like:
PHP:
exec('/usr/local/bin/php your_script.php some_arg1 some_arg2 2>&1', $output, $ret);

If I remember correctly, $output is an array. Each element is one line of the output. In $ret the exit code of the php process is stored. This should be 0 on success.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Each script that runs in a cron job must also run when you put the command directly at your console. If you don't have shell access then try to use the exec function of php.

Try to capture all output of the script. In the exec call you would do something like:
PHP:
exec('/usr/local/bin/php your_script.php some_arg1 some_arg2 2>&1', $output, $ret);

If I remember correctly, $output is an array. Each element is one line of the output. In $ret the exit code of the php process is stored. This should be 0 on success.

Exec is a disabled function on x10hosting.
 
Top