Dynadot — .com Registration $8.99

Running a PHP file in Cron Job

Spaceship Spaceship
Watch

NetworkTown.Net

Account Closed
Impact
2
Hi

Does anyone know how to run a php file in cron job every hour?

what is the command i put in the cron job?

right now i have the following and it does not work

55 * * * * php q- /home/play/public_html/cron.php

What is the right command for this?

Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
to run a php script use the GET clause for eg:

GET /home/play/public_html/cron.php > /dev/null
 
0
•••
Your cron entry is generally right. That way it will run the command hourly five minutes before the full hour.

If it doesnt work nonetheless, your user is either not allowed to run cron jobs or the command cannot be executed. It is better to use absolute paths like /path/to/the/php/directory/php -q /path/to/script.php
 
0
•••
Well i have full rights on my server so what is the best one to use?
 
0
•••
There is no other to use.

Given your user has cron rights, your problem is mostly the non-absolute path. Modify it as I mentioned it previously and it should work.
 
0
•••
And also make sure that if you make any system() calls in your script that you use full paths within those as well.
 
0
•••
cef said:
And also make sure that if you make any system() calls in your script that you use full paths within those as well.
Yes, generally all file system accesses should be done via absolute calls.
 
0
•••
NetworkTown.Net said:
Well i have full rights on my server so what is the best one to use?
You can find the path to php by executing:
which php

On my server, this returned:
/usr/bin/php

So for cron, I'd do something like:
55 * * * * /usr/bin/php -f /home/play/public_html/cron.php
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back