micasa001 Posted August 30, 2013 Share Posted August 30, 2013 I try to run multiple php scripts from 1 folder with cron updates in it. With the script below I like to check all files in the folder (file names are exact the same as the names in the database). The problem is that it seems that my .log files are not loaded. Anybody has a solution for me how I can get this script working? $cron2 = mysql_query("SELECT * FROM `cron` ORDER BY (`name`) DESC LIMIT 0,999"); while ($crondata = mysql_fetch_assoc($cron2)) {//Select runlogs $RunLog = 'includes/crons/' . $crondata->name . '.log'; //make sure you have this file downloaded too if (file_exists($RunLog)) { $lastRun = file_get_contents($RunLog); if (time() - $lastRun >= $crondata->seconds) { //This will check last time file ran. //Select all cronjobs from the database $select = mysql_query("SELECT name FROM `cron` ORDER BY (`name`) DESC LIMIT 0,999"); while ($list = mysql_fetch_assoc($select)) { $cron = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/includes/crons/' . $list[name] . '.php?password=' . $cron_password . ''); // here you put the link for your file or the php code file_put_contents($RunLog, time()); } } }} NOTE: this script is working http://plaatscode.be/142266/ but the problem is that this only run 1 file in the folder and I have multiple script in there. Maybe this will give some help... Thanks for the help. Quote Link to comment Share on other sites More sharing options...
micasa001 Posted August 30, 2013 Author Share Posted August 30, 2013 I changed the script to: //Load correct cron name $cron2 = mysql_query("SELECT * FROM `cron`"); $crondata = mysql_fetch_object($cron2);{ //Select all runlogs $select = mysql_query("SELECT * FROM `cron` ORDER BY (`name`) DESC LIMIT 0,999"); while ($list = mysql_fetch_assoc($select)) { $RunLog = 'includes/crons/' . $list[name] . '.log'; //make sure you have this file downloaded too } if (file_exists($RunLog)) { $lastRun = file_get_contents($RunLog); if (time() - $lastRun >= $crondata->seconds) { //This will check last time file ran. //Select all cronjobs from the database $select = mysql_query("SELECT name FROM `cron` ORDER BY (`name`) DESC LIMIT 0,999"); while ($list = mysql_fetch_assoc($select)) { $cron = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/includes/crons/' . $list[name] . '.php?password=' . $cron_password . ''); // here you put the link for your file or the php code file_put_contents($RunLog, time()); } } } } Quote Link to comment Share on other sites More sharing options...
jcbones Posted August 30, 2013 Share Posted August 30, 2013 Why not just use glob. There shouldn't be a reason to use a database for this, unless you are storing when it was executed (but you could write that back to a file, also). Quote Link to comment 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.