![]() |
Cron Jobs - why doesn't this work
Sorry for that messy post, I forgot HTML is on :) IM posting that again:
I wrote a simple script (source: http://www.hypergals.com/gal_update.txt ). When I run it from my browser, everything works fine and without errors, but when I order cronjobs to run it every midnight, these errors occur when executed: /home/phrona/public_html/gal_update.php: line 1: ?: No such file or directory /home/phrona/public_html/gal_update.php: line 2: syntax error near unexpected token `'gal_today.html','gal_yesterday.html'' /home/phrona/public_html/gal_update.php: line 2: ` copy('gal_today.html','gal_yesterday.html'); ?>' My hosting support done its best, but nothing helped. Absolute paths in the source didn't worked. Thanks for answer |
Does the script use absolute or relative file paths?
|
sorry I told it wrong - the script can use both absolute and relative paths and it returns the same errors.
|
how do you execute this script?
(what is your cron line) |
are you useing 'cron' as root or as a 'user'? and i am SURE that any cron routine must use absolute paths?
|
Quote:
Minutes/Hours/Days/Weeks/Months/command 0 0 * * * /home/phrona/public_html/gal_update.php |
add
#!/usr/local/bin/php as the first line of your script, unless you're excuting the script such as /usr/local/bin/php gal_update.php from your crontab. Also, the path to the php binary file may be different than your location so double check that. You'll also need to set execute permissions. chmod 755 gal_update.php |
have you tried run php scripts from shell ?
maybe you should just use lynx 0 0 * * * /usr/bin/lynx -dump http://www.mydomain.com/myscript.php > /dev/null 2>&1 just change /usr/bin/lynx to anything what 'which lynx' shows (which lynx - run this from shell) |
Quote:
/bin/sh: /home/phrona/public_html/gal_update.php: /home/phrona/public_html/: bad interpreter: Permission denied Of course I chmoded gal_update.php. |
edited -mistake
|
I ran into a similar problem with a couple of scripts. This is from the documentation of PhpAds. It seems that if you want to run a php script with cron, you have to use commands similar to these.
------------------------------------- Depending on the configuration of your server you can use one of the following tools to actually run the maintenance file: curl, fetch, lynx or wget. To find out which is supported by your server simply type the name of the tool on the command-line. If you get a message ?command not found? the tool isn?t supported on your server. # if your server supports curl: 0 * * * * curl -s -o /dev/null http://your.server.name.here/phpAdsN...aintenance.php # if your server supports fetch: 0 * * * * fetch -o /dev/null http://your.server.name.here/phpAdsN...aintenance.php # if your server supports lynx: 0 * * * * lynx > /dev/null -dump http://your.server.name.here/phpAdsN...aintenance.php # if your server supports wget: 0 * * * * wget -q -O /dev/null http://your.server.name.here/phpAdsN...aintenance.php ------------------------------------------------------ On my box, it was the wget command that did the trick. Hope this helps..... |
funny.. fucking with cron as well since a long time.. as we type..
|
I had problems similar to that. This is kind of stupid how I looped it like this but that is how I got it to work
0 8 * * * /home/htdocs/domain/www/update.txt update.txt: cd /home/htdocs/domain/cgi-bin; ./script.pl; |
Quote:
This is the easiest solution, there are others. Replace: /home/phrona/public_html/gal_update.php With: wget --spider -q http://www.hypergals.com/gal_update.php The other common solution requires the PHP binary. |
create a file called gal_update.bat
put in it: Quote:
|
Quote:
|
Quote:
|
All times are GMT -7. The time now is 08:03 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123