Need Cron Help Badly

TheOutfit

New Member
Messages
24
Reaction score
0
Points
0
first off, Sorry if this is in wrong topic, this just seems a logical palce to put it.
-----
Im makin a Text-Based RPG game (theoutfit.exofire.net/outfit/index.php)
& i have a cron writtin to make the health,Brave (nerve,courage w/e u wanna call it) & will go up every 5 minutes. I dont think my coding is wrong but here it is:

<?php​
include "mysql.php";
global $c, $mykey;
$path=$_SERVER['HTTP_HOST'].str_replace('cron_fivemins.php','',$_SERVER['SCRIPT_NAME']);
if($_GET['code'] != md5($path.$mykey))
{
exit;
}
$query="UPDATE users SET energy=energy+(maxenergy/(12.5)) WHERE energy<maxenergy";
$query2="UPDATE users SET energy=maxenergy WHERE energy>
maxenergy";
$query3="UPDATE users SET will=will+10 WHERE will<maxwill";
$query4="UPDATE users SET will=maxwill WHERE will>
maxwill";
mysql_query($query,$c) or die("\nError Executing Query 1 for updating users $i to $next\n$query\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query2,$c) or die("\nError Executing Query 2 for updating users $i to $next\n$query2\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query3,$c) or die("\nError Executing Query 3 for updating users $i to $next\n$query3\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query4,$c) or die("\nError Executing Query 4 for updating users $i to $next\n$query4\n".mysql_error()."\nError Code:".mysql_errno());
$query="UPDATE users SET brave=brave+((maxbrave/10)+0.5) WHERE brave<maxbrave ";
$query2="UPDATE users SET brave=maxbrave WHERE brave>
maxbrave";
$query3="UPDATE users SET hp=hp+(maxhp/3) WHERE hp<maxhp";
$query4="UPDATE users SET hp=maxhp WHERE hp>
maxhp";
mysql_query($query,$c) or die("\nError Executing Query 1 for updating users $i to $next\n$query\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query2,$c) or die("\nError Executing Query 2 for updating users $i to $next\n$query2\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query3,$c) or die("\nError Executing Query 3 for updating users $i to $next\n$query3\n".mysql_error()."\nError Code:".mysql_errno());
mysql_query($query4,$c) or die("\nError Executing Query 4 for updating users $i to $next\n$query4\n".mysql_error()."\nError Code:".mysql_errno());
?>
---Thats Code
& its directory should be: /home/trill07/public_html/outfit/cron_fivemins.php
But i was readin a tutorial by cory sayin to do this:
php -q/home/trill07/public_html/cron_fivemins.php . wich seeing as the other directory didnt work i decided to try that, Still nothing. i have the time thing set to: 5-0-*-*-*
--
Anyone tell me whats wrong id REALLY appreciate it
Edit:
I know i messed up the code.... i fixed it & executed the script manually & it works but it wont work with crontab off of CPanel. Do we have to get it turned on by an admin or something??
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
cron jobs must be written in lunix. just write a lunix script that tells it to run that health file...
 

KentonBomb

New Member
Messages
42
Reaction score
0
Points
0
I've fixed it for TheOutfit. The problem was the If...Then statement near the beginning of the script made it exit before it executed the Mysql query's.

:lol:
 

masshuu

Head of the Geese
Community Support
Enemy of the State
Messages
2,293
Reaction score
50
Points
48
cron jobs must be written in lunix. just write a lunix script that tells it to run that health file...

a cron script is basicly a "run this program at this time" and you can have it run php scripts, which if theres any output, it normally emails it to the user.
 

deadimp

New Member
Messages
249
Reaction score
0
Points
0
You might want to turn it down from 5 minutes to something like every two hours. Even though your script doesn't seem to be that intense, you might run the risk of getting suspended by having a CRON script execute too frequently. I'm not sure, though. You may need to ask an account manager (in the support forums).

Another suggestion: I'm not a SQL-buff, so I don't know how you could really compress that, but I'd suggest using arrays just to make it a little simpler. Ex.
Code:
$query_list=array(
 'query 1',
 'query 2',
 ... );
foreach ($query_list as $index => $query) {
 mysql_query($query,$c) or die("Problem with query $index ...");
}
 
Top