Help To Run CronJob

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Help To Run CronJob

Post 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
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Re: Help To Run CronJob

Post 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
bestcanyonlakehomes
Forum Newbie
Posts: 1
Joined: Mon Jan 11, 2010 8:40 am

Re: Help To Run CronJob

Post by bestcanyonlakehomes »

thanks shafiq!
Post Reply