[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-04-2007, 09:41 AM   #1 (permalink)
Account Closed
 
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
55.39 NP$ (Donate)

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, 09:43 AM   #2 (permalink)
Senior Member
 
dc1pop's Avatar
 
Join Date: Dec 2004
Location: UK
Posts: 1,894
110.80 NP$ (Donate)

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, 11:58 AM   #3 (permalink)
NamePros Regular
 
Join Date: Oct 2006
Posts: 918
40.00 NP$ (Donate)

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

muov.com • qeww.com • sejz.com • viuo.com • vuav.com • wzeo.com • xeib.com • xueo.com

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 12:44 PM   #4 (permalink)
Account Closed
 
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
55.39 NP$ (Donate)

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, 12:53 PM   #5 (permalink)
NamePros Regular
 
Join Date: Oct 2006
Posts: 918
40.00 NP$ (Donate)

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

muov.com • qeww.com • sejz.com • viuo.com • vuav.com • wzeo.com • xeib.com • xueo.com

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 12:58 PM   #6 (permalink)
cef
NamePros Regular
 
Join Date: May 2004
Location: NYC
Posts: 236
76.50 NP$ (Donate)

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, 12:59 PM   #7 (permalink)
NamePros Regular
 
Join Date: Oct 2006
Posts: 918
40.00 NP$ (Donate)

neroux has a spectacular aura aboutneroux has a spectacular aura about


Quote:
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

muov.com • qeww.com • sejz.com • viuo.com • vuav.com • wzeo.com • xeib.com • xueo.com

-- Do not let others be treated this way!
neroux is offline  
Old 08-04-2007, 03:49 PM   #8 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services

 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Quote:
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:
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 10:10 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85