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
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
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.Code:/usr/bin/php /home/igor/public_html/cron_job.php >>/home/igor/public_html/cron_log.txt 2>&1
Timing:
Will run your once a day job at 12:00 Midnight.Code:0 0 * * *
Next, you want your once an hour job.
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:0 * * * *
Lastly, you want your 5 minute job.Code:30 * * * *
If you set it to:
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 * * * *
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:0,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 * * * *
The schedule all the restCode:5,10,15,20,25,35,40,45,50,55 0 * * *
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.
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 toheres the code
this is the 5 minute cron by the wayPHP 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'] == 5 && $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");
}
?>
Last edited by daron0382; 04-12-2011 at 05:26 PM.
Are you calling this cron via wget or curl ? That is the only way $_GET would have values.Code:if($_GET['code'] != $_CONFIG['code']) { die(""); }
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.
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.Code:$result = $db->query($query); echo "First update returned: $result \n":
Nothing is always absolutely so.
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.
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.
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
Will call your webpage/cronjob. NOTE: it is -O - , ie hyphen capital O (not zero 0 ) space hyphenCode:wget -O - http://nameOfYourSite.x10.bx/cron_fivemins.php?code=YourSecretCode >>/home/igor/public_html/cron_log.txt 2>&1
Nothing is always absolutely so.