Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About resetRun() #64

Closed
playinteractive opened this issue Sep 15, 2018 · 2 comments
Closed

About resetRun() #64

playinteractive opened this issue Sep 15, 2018 · 2 comments

Comments

@playinteractive
Copy link

Hi there,

I'm reading a list of cronjobs from the database but I'm not sure how to use resetRun():

$listCron = $db->query(bla bla bla)

while {

$scheduler->php($file)->at($schedule);
$scheduler->resetRun()->run();
}

or maybe:

while {

$scheduler->php($file)->at($schedule);
}

$scheduler->run();

Many thanks,

@peppeocchi
Copy link
Owner

@playinteractive the second block of code is the correct, you might need to call resetRun only if you want the same job to run multiple times in the same schedule.

Example

$scheduler->php('job1.php');
$scheduler->php('job2.php');
$scheduler->run();

// Then you want job1 to run again in the same schedule

$scheduler->resetRun();
$scheduler->php('job1');
$scheduler->run();

@joshp23
Copy link

joshp23 commented Sep 16, 2019

@peppeocchi

For clarity, I have the following wrapped in a function which is called by scheduler.php

	$scheduler = new Scheduler();

        $jobs = $db->querry;

	foreach ( $jobs as $job ) {
		$job[1] = $function;
		$job[2] = $schedule;
		$scheduler->call($function)->at($schedule)->onlyOne();
	}

	$scheduler->run();

In this instance there is no need to use either clearJobs() or resetRun() when calling this every minute, yes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants