+ Reply to Thread
Results 1 to 5 of 5

Thread: Need Cron Help Badly

  1. #1
    TheOutfit is offline x10Hosting Member TheOutfit is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    24

    Need Cron Help Badly

    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 by TheOutfit; 02-11-2008 at 10:22 PM. Reason: Automerged Doublepost

  2. #2
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Need Cron Help Badly

    cron jobs must be written in lunix. just write a lunix script that tells it to run that health file...
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  3. #3
    KentonBomb's Avatar
    KentonBomb is offline x10Hosting Member KentonBomb is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    42

    Re: Need Cron Help Badly

    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.

    :laugh:

  4. #4
    masshuu's Avatar
    masshuu is offline Head of the Geese masshuu has a spectacular aura about
    Join Date
    Oct 2007
    Location
    Las Colinas, Tx
    Posts
    2,262

    Re: Need Cron Help Badly

    Quote Originally Posted by leafypiggy View Post
    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.
    Just leading the flock.
    Livewire
    Masshuu ------ carl6969
    descalzo ------------------- Smith6612
    Bryon--------------------------------- Corey
    If you find any post helpful or useful, duck
    \ / This for that post and rep it up.

  5. #5
    deadimp is offline x10 Sophmore deadimp is an unknown quantity at this point
    Join Date
    Jun 2007
    Posts
    249

    Re: Need Cron Help Badly

    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 ...");
    }
    deadimp.org
    > Thacmus [v0.3.0] - Open source CMS, PHP 5, MySQL

    "¡Ya lo sabo!" - Lo Ausente

+ Reply to Thread

Similar Threads

  1. CRON Jobs and PHP
    By deadimp in forum Tutorials
    Replies: 14
    Last Post: 11-27-2008, 05:09 PM
  2. mis cron jobs no se guardan
    By stsights in forum Soporte
    Replies: 5
    Last Post: 02-07-2008, 08:41 PM
  3. Cron
    By KingOfTheEmblem in forum Free Hosting
    Replies: 6
    Last Post: 12-09-2007, 07:06 AM
  4. Cron Jobs and Facebook
    By dmallenby in forum Free Hosting
    Replies: 2
    Last Post: 11-14-2007, 10:04 AM
  5. cron jobs help
    By TarinC in forum Scripts & 3rd Party Apps
    Replies: 5
    Last Post: 09-19-2006, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers