Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-14-2005, 12:45 PM cron jobs?
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
I have had problems with cron jobs before where i couldn't find the location of the file i wanted to use so i have been using a script that runs the file when some one visits a page, but this isn't accurate enough, because if no body is online then the file won't get run at all. so i tried cron jobs again, this time i worked out the location of my file, but i get loads of errors when it is run, this is what i get in my email:

Quote:
/vetinari/nacropet/public_html/admin/restock.php: line 1: ?php: No such file or directory
/vetinari/nacropet/public_html/admin/restock.php: line 2: syntax error near unexpected token `"connect.php"'
/vetinari/nacropet/public_html/admin/restock.php: line 2: `include ("connect.php"); '
so i thought maybe you can't include files in a cron job so i put contents of connect.php into the file i'm running but i get this error:

Quote:
/vetinari/nacropet/public_html/admin/restock.php: line 1: ?php: No such file or directory
/vetinari/nacropet/public_html/admin/restock.php: line 2: syntax error near unexpected token `('
/vetinari/nacropet/public_html/admin/restock.php: line 2: `$db = mysql_connect("localhost", "###", "###") or die("Could not connect.");
how can i make this work? is there something you have to add to the file?

Last edited by timsquash5; 03-14-2005 at 12:47 PM..
timsquash5 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-14-2005, 01:14 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
I think you have to specify where the PHP interpreter is, because crontab itself cannot parse PHP.

Try adding the path to your PHP executable before the filename. For example:
Code:
<timing stuff> /usr/local/bin/php /path/to/myfile.php
And I searched Google, you could also create a shell script with a PHP shebang:
Code:
#!/usr/local/bin/php -q
<your code here>
Then put the path to that shell script.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-14-2005, 01:28 PM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
thank you, i just put /usr/local/bin/php before the location of the file and it worked
timsquash5 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to cron jobs?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35631 seconds with 12 queries