Cron job (php script) not sunning?

Status
Not open for further replies.

pietje63

New Member
Messages
21
Reaction score
0
Points
1
Cron job (php script) not running?

I have the following cron jobs configured

script 1, running each 30 minutes (15 and 45 past hour)

Minute
Hour
Day
Month
Weekday
Command
15,45
*
*
*
*
/usr/local/bin/php $HOME/public_html/cronjob.php

script 2, running once in 2 days



Minute
Hour
Day
Month
Weekday
Command
2
*
*
/usr/local/bin/php $HOME/public_html/cronjob2.php
Both scripts run fine from the browser and log to a file. But the cronjobs appear to not be running. Any ideas?
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
How are you checking whether or not the cron jobs are running? Are you logging the output of the PHP scripts?
 

pietje63

New Member
Messages
21
Reaction score
0
Points
1
Yes, I'm logging (via php fwrite) to a file. When I run the file from the browser I see it is working/logging.
 

mraz

New Member
Messages
95
Reaction score
3
Points
0
just curious, because time is set as every 15 and 45 of the hour, have you tried to change it to run every min to test it out?

because needing to wait every 30mins for it run is abit tiring...
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
just curious, because time is set as every 15 and 45 of the hour, have you tried to change it to run every min to test it out?

Every minute is a violation of the TOS and the cron will be discarded.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Yes, I'm logging (via php fwrite) to a file. When I run the file from the browser I see it is working/logging.

No. If there is an error running your script via cron your logging will not do anything.

Use a command line like

Code:
/usr/bin/php   /home/igor/public_html/cron_job.php >>/home/igor/public_html/cron_log.txt 2>&1

where "igor" is your cPanel username.

This will log any "echo" command output along with any failures (file not found, etc).

Not sure if your second script is set to run when you want.
 
Last edited:

pietje63

New Member
Messages
21
Reaction score
0
Points
1
oops sorry - every 5 mins then
I choosed for 15,45 to eb able to run both cron jobs together.

I thought testing by 'browsing' was fine, and than run the script each thirty minutes. I'm not that much in a hurry that I need to run it more often. Would you expect anything else by editing the run frequency?

No. If there is an error running your script via cron your logging will not do anything.

Use a command line like

Code:
/usr/bin/php   /home/igor/public_html/cron_job.php >>/home/igor/public_html/cron_log.txt 2>&1

where "igor" is your cPanel username.

This will log any "echo" command output along with any failures (file not found, etc).

Not sure if your second script is set to run when you want.

Thank you. That is a fair point. Will try tonight.

Logging added; will report test of log later. Timing was indeed incorrect, now also updated

It looks like the script is running :) probably the path to fwrite is different when running cron-php compared to 'normal'.

Thanks for all input!
 
Last edited:
Status
Not open for further replies.
Top