|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
Quote:
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. |
|
#6
|
|||
|
|||
|
Ahhh, right.
Many thanks. |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > using cron to run a php script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|