Welcome to WebmasterWorld Guest from 54.162.155.183

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

cron problems with php

     
2:11 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello all, i have come across a problem when trying to set a crontab job (a simple script to email me some stats).

I get an error message : syntax error near unexpected token mysql_connect(" .

First Lines of script are:
<? // line1
$server_connect = mysql_connect("localhost", "user", "pass"); // line2
$db_connect = mysql_select_db("dbname", $server_connect) or die("Cannot Connect to Database");// line3

Am i doing somethig wrong?
The cron is set to run as root from: /home/username/www/foldername/filename.php

3:02 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi omoutop,

Have you tried accessing the file in your browser to see what you get?

dc

6:36 am on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the file works fine through browser... anything else i should be aware of?
6:41 am on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Try setting the cron tab as:

php -q /home/username/www/foldername/filename.php

dc

9:23 am on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the php -q /home/username/www/foldername/filename.php option didnt seem to work either..

anyway i finally managed to run the script as it was supposed to run...

wget [mysite.com...]
with {folder} and script_to_run.php set to 777

Thanks for the advice dc (because since you saw me i could call an exe, perhaps i could call a virtual browser (or at least this is how i understand the wget))! :)

3:02 pm on May 21, 2006 (gmt 0)

5+ Year Member



You typically need two things...

1.) Path to PHP
2.) The path to the PHP script

/usr/bin/php /var/www/vhosts/yourdomain.com/httpdocs/emailscript.php >/dev/null 2>&1

(all on one line)

Works for me on Plesk.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month