R1der Posted October 14, 2006 Share Posted October 14, 2006 I dont know if i am in the right place to post this.Ok i am trying to run a cron but keep getting a error come in my inbox. i am very new to using crons.This is the error/home/lostcity/public_html/crons/cron24r.php: line 1: ?: No such file or directory/home/lostcity/public_html/crons/cron24r.php: line 2: syntax error near unexpected token `('/home/lostcity/public_html/crons/cron24r.php: line 2: `$db->query("UPDATE users SET uAttackTurns=uAttackTurns+2 WHERE uAttackTurns<uAttackTurnsMax AND (uType=1 OR uType=2)");This is my code[code]<?$db->query("UPDATE users SET uAttackTurns=uAttackTurns+2 WHERE uAttackTurns<uAttackTurnsMax AND (uType=1 OR uType=2)");?>[/code]Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/ Share on other sites More sharing options...
AndyB Posted October 14, 2006 Share Posted October 14, 2006 Does cron24r.php actually work when run directly, rather than as a cron task? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108888 Share on other sites More sharing options...
akitchin Posted October 14, 2006 Share Posted October 14, 2006 if you're trying to run the file directly in a CRON, you need to add this line to the top:[code]#!/usr/bin/php -q<?php// php here?>[/code]this tells the command line to parse the following PHP code with the php engine (as far as i know), in quiet mode which suppresses the headers. the /usr/bin/php might need to change depending on your hosting setup. check phpinfo() for the proper path if this doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108889 Share on other sites More sharing options...
R1der Posted October 14, 2006 Author Share Posted October 14, 2006 yes it does.a little more detaili have the cronjob reading crontab.txtcrontab.txt contains the following/home/lostcity/public_html/crons/cron24r.phpSo it reads crontab.txt ok but it wont read cron24r.phpI dont understand why :( Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108891 Share on other sites More sharing options...
R1der Posted October 14, 2006 Author Share Posted October 14, 2006 [quote author=akitchin link=topic=111511.msg451954#msg451954 date=1160863637]if you're trying to run the file directly in a CRON, you need to add this line to the top:[code]#!/usr/bin/php -q<?php// php here?>[/code]this tells the command line to parse the following PHP code with the php engine (as far as i know), in quiet mode which suppresses the headers. the /usr/bin/php might need to change depending on your hosting setup. check phpinfo() for the proper path if this doesn't work.[/quote]So i add that to crontab.txt or cron24r.php?And thx for the replys Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108892 Share on other sites More sharing options...
R1der Posted October 14, 2006 Author Share Posted October 14, 2006 ok i added that to cron24r.phpAnd now i dont get the error im my inbox but the database dont update :(altho if i run cron24r.php on my browser it works fine and updates the databaseAny ideas? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108896 Share on other sites More sharing options...
akitchin Posted October 14, 2006 Share Posted October 14, 2006 are you connecting to the database in the cron24r.php?add an or die() clause to your query. any output from the script should go to your inbox. Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108897 Share on other sites More sharing options...
R1der Posted October 14, 2006 Author Share Posted October 14, 2006 i am connecting to the database via a include file there is a or die in the include fileI dont get anything come in my email at all now - errors or sucseed Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108898 Share on other sites More sharing options...
R1der Posted October 15, 2006 Author Share Posted October 15, 2006 ok sorted the cron prob Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-108989 Share on other sites More sharing options...
neylitalo Posted October 15, 2006 Share Posted October 15, 2006 Can you tell us what you did to fix it? It may help some poor soul in the future. Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-109147 Share on other sites More sharing options...
R1der Posted October 16, 2006 Author Share Posted October 16, 2006 Well i just did what akitchin said.[quote]if you're trying to run the file directly in a CRON, you need to add this line to the top:Code:#!/usr/bin/php -q<?php// php here?>this tells the command line to parse the following PHP code with the php engine (as far as i know), in quiet mode which suppresses the headers. the /usr/bin/php might need to change depending on your hosting setup. check phpinfo() for the proper path if this doesn't work.[/quote]But it worked fine for a few days then i started getting another error in my mailboxThis is the errorError in argument 1, char 3: option not found Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] php <file> [args...] -a Run interactively -C Do not chdir to the script's directory -c <path>|<file> Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f <file> Parse <file>. Implies `-q' -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -q Quiet-mode. Suppress HTTP Header output. -s Display colour syntax highlighted source. -v Version number -w Display source with stripped comments and whitespace. -z <file> Load Zend extension <file>.Anyone understand this? If so any ideas to fix it?Thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-109432 Share on other sites More sharing options...
akitchin Posted October 16, 2006 Share Posted October 16, 2006 as far as i know, it means that it thinks 'q' is an option that doesn't exist. i've gotten that error before and frankly, i don't know why it comes back seeing as in the usage explanation it clearly shows 'q' as a legit option.someone who's good with linux command line care to help out here? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-109727 Share on other sites More sharing options...
neylitalo Posted October 16, 2006 Share Posted October 16, 2006 I'm afraid I don't see the -q switch in my php -h, and don't see any flags to enable when you ./configure, am I missing something?And out of curiosity, why do we need to suppress headers? Are there even going to be any headers sent, since it's being run through the CLI? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-109735 Share on other sites More sharing options...
akitchin Posted October 16, 2006 Share Posted October 16, 2006 the headers are sent regardless of being run by CLI or the web server unless the quiet mode is set, as far as i know. i've used the -q option on plenty of servers, so i'm starting to wonder if it's only available on certain servers? Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-109746 Share on other sites More sharing options...
R1der Posted October 26, 2006 Author Share Posted October 26, 2006 Well i removed the "-q" from the script now and all is working fine.Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/23959-solved-solved-cron/#findComment-115054 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.