GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Cron Jobs - why doesn't this work (https://gfy.com/showthread.php?t=224757)

Phrona 01-23-2004 08:25 AM

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

NetRodent 01-23-2004 08:32 AM

Does the script use absolute or relative file paths?

Phrona 01-23-2004 08:36 AM

sorry I told it wrong - the script can use both absolute and relative paths and it returns the same errors.

Anothers 01-23-2004 08:39 AM

how do you execute this script?

(what is your cron line)

WebTitan 01-23-2004 08:41 AM

are you useing 'cron' as root or as a 'user'? and i am SURE that any cron routine must use absolute paths?

Phrona 01-23-2004 08:47 AM

Quote:

Originally posted by Anothers
how do you execute this script?

(what is your cron line)

I have currently 3 cronjobs placed and 2 (cgi) of them work, this (php) doesnt, so I don't expect the error to be here. I don't type whole row, there is user friendly control panel:

Minutes/Hours/Days/Weeks/Months/command

0 0 * * * /home/phrona/public_html/gal_update.php

notjoe 01-23-2004 08:49 AM

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

Anothers 01-23-2004 08:52 AM

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)

Phrona 01-23-2004 09:06 AM

Quote:

Originally posted by notjoe
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

I did what you said and I received this error:

/bin/sh: /home/phrona/public_html/gal_update.php: /home/phrona/public_html/: bad interpreter: Permission denied

Of course I chmoded gal_update.php.

Phrona 01-23-2004 09:07 AM

edited -mistake

Scuzz 01-24-2004 11:51 PM

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.....

mrthumbs 01-24-2004 11:58 PM

funny.. fucking with cron as well since a long time.. as we type..

kenny 01-25-2004 12:10 AM

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;

RK 01-25-2004 12:18 AM

Quote:

Originally posted by Phrona
My hosting support done its best, but nothing helped. Absolute paths in the source didn't worked.
That is just sad; this is a very obvious issue.
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.

goBigtime 01-25-2004 12:20 AM

create a file called gal_update.bat

put in it:

Quote:

#!/bin/sh

cd /home/phrona/public_html

/usr/local/bin/php /home/phrona/public_html/gal_update.php
then chmod 755 gal_update.bat and call it from your cron job.

goBigtime 01-25-2004 12:26 AM

Quote:

Originally posted by Scuzz - edited by gobigtime


# If you run linux or freebsd your server should have wget
0 * * * * wget -q -O /dev/null http://www.yourdomain.com/gal_update.php

If you use a solution like the one above, then be sure to limit access to that script so that only the boxes local IP can acccess it.

RK 01-25-2004 12:56 AM

Quote:

Originally posted by goBigtime


If you use a solution like the one above, then be sure to limit access to that script so that only the boxes local IP can acccess it.

Or do it the easy way and just don't tell anyone the URL :)


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