NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Running a PHP file in Cron Job

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-04-2007, 10:41 AM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Running a PHP file in Cron Job


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
NetworkTown.Net is offline  
Old 08-04-2007, 10:43 AM   #2 (permalink)
Senior Member
 
dc1pop's Avatar
Join Date: Dec 2004
Location: UK
Posts: 1,893
dc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to beholddc1pop is a splendid one to behold
 



to run a php script use the GET clause for eg:

GET /home/play/public_html/cron.php > /dev/null
dc1pop is offline  
Old 08-04-2007, 12:58 PM   #3 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



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
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 01:44 PM THREAD STARTER               #4 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Well i have full rights on my server so what is the best one to use?
NetworkTown.Net is offline  
Old 08-04-2007, 01:53 PM   #5 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



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.
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 01:58 PM   #6 (permalink)
cef
NamePros Regular
Join Date: May 2004
Location: NYC
Posts: 236
cef is a jewel in the roughcef is a jewel in the roughcef is a jewel in the rough
 


Animal Rescue
And also make sure that if you make any system() calls in your script that you use full paths within those as well.
cef is offline  
Old 08-04-2007, 01:59 PM   #7 (permalink)
NamePros Regular
Join Date: Oct 2006
Posts: 963
neroux has a spectacular aura aboutneroux has a spectacular aura about
 



Originally Posted by cef
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.
__________________
Paris loves CityPics

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 04:49 PM   #8 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Originally Posted by NetworkTown.Net
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:
????: NamePros.com http://www.namepros.com/programming/357798-running-a-php-file-cron-job.html
Quote:
which php
On my server, this returned:
Quote:
/usr/bin/php
So for cron, I'd do something like:
Quote:
55 * * * * /usr/bin/php -f /home/play/public_html/cron.php
Eric is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:06 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger