Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old July 1st, 2005, 05:39 AM
Nigel Ll-D Nigel Ll-D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 15 Nigel Ll-D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 56 m 17 sec
Reputation Power: 0
using cron to run a php script

Hi there,

I am trying to run a php script on a timed basis using cron. I have set up the cron job on cpanel, with the command being home/username/public_html/scriptname.php.

It finds the file, but seems to read it for further commands, rather than executing it, producing the following results in the output.

/home/pricetas/public_html/control/scripts/cronupload.php: line 1: ?php: No such file or directory
/home/pricetas/public_html/control/scripts/cronupload.php: line 2: =Output results from uploadall.php /n: No such file or directory
/home/pricetas/public_html/control/scripts/cronupload.php: line 4: syntax error near unexpected token `'connect.php''
/home/pricetas/public_html/control/scripts/cronupload.php: line 4: `include ('connect.php');'

My question is what should the file that cron is directed to contain to run, for example, cronupload.php ?

Many thanks

Nigel

Reply With Quote
  #2  
Old July 1st, 2005, 06:53 AM
Nigel Ll-D Nigel Ll-D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 15 Nigel Ll-D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 56 m 17 sec
Reputation Power: 0
Worked it out.

If anyone is wondering how to do this, I have worked it out...

Because php needs to go through apache to be 'interpreted' you need to use wgets to simulate your file being called through a browser.

so the cron command will be whatever time and dates you would like it run followed by

wget http://www.domain.com/script.php

Bingo

Reply With Quote
  #3  
Old July 1st, 2005, 08:05 AM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Alternately, check out this.

Reply With Quote
  #4  
Old July 1st, 2005, 08:54 AM
Nigel Ll-D Nigel Ll-D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 15 Nigel Ll-D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 56 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by wdn2000
Alternately, check out this.


Errrr,

Sorry, didn't quite understand anything on that page. Which part is related to automatically running scripts?

Reply With Quote
  #5  
Old July 1st, 2005, 09:25 AM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by Nigel Ll-D
Errrr,

Sorry, didn't quite understand anything on that page. Which part is related to automatically running scripts?


None of it. That wasn't the stated problem. You said you had cron working but you were having trouble with actually executing the PHP, thus the suggestion.

Depending on how you have PHP set up on your server you could use different methods, as descibed in the manual, to execute the script. My personal favorite it to make my PHP run like a shell script by adding:

#!/usr/bin/php (or whatever your path is)

to the begining and chmodding the file to be executable, but YMMV.

Reply With Quote
  #6  
Old July 1st, 2005, 11:34 AM
Nigel Ll-D Nigel Ll-D is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 15 Nigel Ll-D User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 56 m 17 sec
Reputation Power: 0
Ahhh, right.
Many thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > using cron to run a php script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway