Page 1 of 1

Help To Run CronJob

Posted: Fri Dec 11, 2009 12:10 am
by shafiq2626
Hi!
my cronjob run but give an error in my php file like that

/home/contacse/public_html/cronjob.php: line 1: ?php: No such file or directory
/home/contacse/public_html/cronjob.php: line 3: syntax error near unexpected token
`'localhost','contacse_project','
/home/contacse/public_html/cronjob.php: line 3: `mysql_connect
('localhost','contacse_project','


If I execute this file myself then this is ok but when cronjob execute this file then give above errors.
Please help me that what is the solution for this.
Thanking you

Re: Help To Run CronJob

Posted: Fri Dec 11, 2009 1:08 am
by shafiq2626
This is Solved to adding following lines.
add php -f / before your path of your file this will be written like this
php -f /home/contacse/public_html/cronjob.php


contacse this is username your user name will be different.

and also add this line before <?php in your cronjob file.

this will be like this.

Code: Select all

#!/usr/bin/php
 
 <?php 
//your code
 
 
?>
Now
Be Happy with this code

Re: Help To Run CronJob

Posted: Mon Jan 11, 2010 8:44 am
by bestcanyonlakehomes
thanks shafiq!