+ Reply to Thread
Results 1 to 8 of 8

Thread: Cron trouble

  1. #1
    daron0382 is offline x10Hosting Member daron0382 is an unknown quantity at this point
    Join Date
    Apr 2011
    Location
    Maryland or in my Laptop
    Posts
    10

    Cron trouble

    hey can someone help me out with cron jobs?? I don't use none smaller than 5 minutes but they still never work. I have a 5 minute, 1 hour & 1 day cron(s) can some guide me on how to properly set up cron jobs.

    Sent from my LG-P509 using Tapatalk

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Cron trouble

    Code:
    /usr/bin/php /home/igor/public_html/cron_job.php >>/home/igor/public_html/cron_log.txt 2>&1
    Is a command line that will run the PHP script and log any output or error messages. You can place the script and log file anywhere.

    Timing:

    Code:
    0 	0 	* 	* 	*
    Will run your once a day job at 12:00 Midnight.

    Next, you want your once an hour job.

    Code:
    0 	* 	* 	* 	*
    is what the cPanel would give you using the 'Common Settings', but that will also go off at 12:00 midnight. Against the TOS. So, have it go off at half past the hour instead:

    Code:
    30 	* 	* 	* 	*
    Lastly, you want your 5 minute job.

    If you set it to:

    Code:
    0/5	* 	* 	* 	*
    It will go off at half past each hour. Same as your hourly job. Against T.O.S. So you have to improvise, having it skip that time:

    Code:
    0,5,10,15,20,25,35,40,45,50,55 	* 	* 	* 	*
    But this goes off at midnight too. Against T.O.S. Easiest way is to adjust it so it does not go off on the hour:

    Code:
    5,10,15,20,25,35,40,45,50,55 	* 	* 	* 	*
    If you want to squeeze in as many as possible, replace the one line with two. First schedule the ones for the midnight hour:

    Code:
    5,10,15,20,25,35,40,45,50,55 	0 	* 	* 	*
    The schedule all the rest

    Code:
    0,5,10,15,20,25,35,40,45,50,55 	1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 	* 	* 	*
    Nothing is always absolutely so.

  3. #3
    daron0382 is offline x10Hosting Member daron0382 is an unknown quantity at this point
    Join Date
    Apr 2011
    Location
    Maryland or in my Laptop
    Posts
    10

    Re: Cron trouble

    Thank you so much!!!! This is the best help i ever had on crons. i am enetering them now, hopefully theey work. i will get back to you to inform you if they worked or not.

    ---------- Post added at 10:25 PM ---------- Previous post was at 09:01 PM ----------

    alright so the crons work now. BUT problem is, there not refilling the brave, energy, & will like they are suppose to heres the code
    PHP Code:
    <?php
    include "config.php";
    global 
    $_CONFIG;
    if(
    $_GET['code'] != $_CONFIG['code']) { die(""); }
    define("MONO_ON"1);
    require 
    "class/class_db_{$_CONFIG['driver']}.php";
    $db=new database;
    $db->configure($_CONFIG['hostname'],
     
    $_CONFIG['username'],
     
    $_CONFIG['password'],
     
    $_CONFIG['database'],
     
    $_CONFIG['persistent']);
    $db->connect();
    $c=$db->connection_id;
    $set=array();
    $settq=$db->query("SELECT * FROM settings");
    while(
    $r=$db->fetch_row($settq))
    {
    $set[$r['conf_name']]=$r['conf_value'];
    }
    //brave update
    $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";
    $query6="UPDATE users SET dexterity=dexterity+5 WHERE dexterity < max_dexterity";
    $query7="UPDATE users SET dexterity=max_dexterity WHERE dexterity > max_dexterity";
    $db->query($query);
    $db->query($query2);
    $db->query($query3);
    $db->query($query4);
    $db->query($query6);
    $db->query($query7);
    //enerwill update
    $query="UPDATE users SET energy=energy+(maxenergy/(12.5)) WHERE energy<maxenergy AND donatordays=0";
    $query5="UPDATE users SET energy=energy+(maxenergy/(6)) WHERE energy<maxenergy AND donatordays>0";
    $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";
    $db->query($query);
    $db->query($query5);
    $db->query($query2);
    $db->query($query3);
    $db->query($query4);
    if(
    $set['validate_period'] == && $set['validate_on'])
    {
    $db->query("UPDATE users SET verified=0");
    }
    if(
    $set['validate_period'] == 15 && $set['validate_on'] && in_array(date('i'),array("00""15""30""45")))
    {
    $db->query("UPDATE users SET verified=0");
    }
    ?>
    this is the 5 minute cron by the way
    Last edited by daron0382; 04-12-2011 at 05:26 PM.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Cron trouble

    Code:
    if($_GET['code'] != $_CONFIG['code']) { die(""); }
    Are you calling this cron via wget or curl ? That is the only way $_GET would have values.

    Step one would be to put a message in the die(), so you can see (it will end up in the log file you set up on the cron command line) that you have a problem there.

    Code:
    $result = $db->query($query);
    
    echo "First update returned: $result \n":
    Not familiar with the db library you are using, but they usually return the number of rows affected. The echo will print to the log file.
    Nothing is always absolutely so.

  5. #5
    daron0382 is offline x10Hosting Member daron0382 is an unknown quantity at this point
    Join Date
    Apr 2011
    Location
    Maryland or in my Laptop
    Posts
    10

    Re: Cron trouble

    no i didnt use curl. would i add curl to the cron command or the cron.php? a friend said in the command but i trust u more. besides his format was different he said something like Curl http://www.blah.com/cron_fivemins.php

    ---------- Post added at 07:42 PM ---------- Previous post was at 03:12 PM ----------

    now i get

    /bin/sh: CURL: command not found
    it says that in the emails.

  6. #6
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Cron trouble

    Ok. I assume you are supposed to call it via the web htt://yadda.com/cronjob.php?yourSpecialCodeHere. Give me a bit to check how the current system is set up to see what works here.
    Nothing is always absolutely so.

  7. #7
    daron0382 is offline x10Hosting Member daron0382 is an unknown quantity at this point
    Join Date
    Apr 2011
    Location
    Maryland or in my Laptop
    Posts
    10

    Re: Cron trouble

    okay cool & thanx for taking the time to work me through this, i been added to ur reputation

    ---------- Post added at 08:26 PM ---------- Previous post was at 08:17 PM ----------

    /bin/sh:
    https://****.x10.mx/cron_fivemins.php?code: No such
    file or directory

    ---------- Post added at 08:57 PM ---------- Previous post was at 08:26 PM ----------

    i fixed it!!!! php -q /home/*****/public_html/cron_fivemins.php that is what i used
    Last edited by descalzo; 04-13-2011 at 04:04 PM. Reason: url/username edited out

  8. #8
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Cron trouble

    Code:
    wget -O -  http://nameOfYourSite.x10.bx/cron_fivemins.php?code=YourSecretCode >>/home/igor/public_html/cron_log.txt 2>&1
    Will call your webpage/cronjob. NOTE: it is -O - , ie hyphen capital O (not zero 0 ) space hyphen
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. Cron trouble
    By kbjradmin in forum Programming Help
    Replies: 8
    Last Post: 03-08-2010, 02:09 PM
  2. Replies: 6
    Last Post: 11-14-2009, 06:38 PM
  3. Can a cron job kick off another cron job?
    By dmoneyman in forum Programming Help
    Replies: 8
    Last Post: 04-03-2009, 08:04 PM
  4. having trouble getting php script to work with cron
    By mikehunt22 in forum Free Hosting
    Replies: 1
    Last Post: 11-02-2008, 09:43 AM
  5. [cron problem]php-cron command not found
    By N4rk0 in forum Free Hosting
    Replies: 1
    Last Post: 01-31-2008, 11:51 AM

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