Jump to content

Simulate cron script multiple files


micasa001

Recommended Posts

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.

Link to comment
Share on other sites

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());
            }
        }
    }
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.