dev-master
9999999-devPHP task scheduler
MIT
The Development Requires
0.2.0
0.2.0.0PHP task scheduler
MIT
The Development Requires
0.1.0
0.1.0.0PHP task scheduler
MIT
The Development Requires
Wallogit.com
2017 © Pedro Peláez
PHP task scheduler
PHPNotifier - is a task scheduler. Allows you to schedule a task that will be executed at any time you wish., (*2)
add to your composer.json - "krydos/php-notifier": "*", (*3)
First of all you have to run a script that will be listening for new tasks and execute them when time came., (*4)
php ./vendor/bin/phpnotifier /absolute/path/to/db.file, (*5)
or if you want to leave it working in background, (*6)
nohup php ./vendor/bin/phpnotifier /absolute/path/to/db.file & >/dev/null 2>&1 &, (*7)
Using nohup you can see log output in nohup.out file., (*8)
How to create new tasks:, (*9)
use \PHPNotifier\PHPNotifier;
$scheduler = new PHPNotifier(PHPNotifier::FILE_METHOD, '/absolute/path/to/db.file');
$scheduler->scheduleTaskIn(10, 'echo', [
'Hello world!'
'>'
'any_file'
]);
This task will be executed in 10 seconds. Command that will be executed is echo Hello world! > any_file, (*10)
Since sometimes you know exact time when you want to run a task and you don't want to calculate how many time is remaining
there is another method exists - scheduleTaskAtTime with same signature., (*11)
use \PHPNotifier\PHPNotifier;
$scheduler = new PHPNotifier(PHPNotifier::FILE_METHOD, '/absolute/path/to/db.file');
$scheduler->scheduleTaskAtTime(1459382400, 'echo', [
'Hello world!'
'>'
'any_file'
]);
This method accepts unix timestamp or \DateTime object as first argument. If you use DateTime PHP's object you can get this value by getTimestamp() method., (*12)
make sure that binary you're trying to execute is exists in your system, (*13)
scheduleTaskAtTime method~~scheduleTaskAtTime method~~There are no special rules. Just send a pull request or create an issue., (*14)
PHP task scheduler
MIT
PHP task scheduler
MIT
PHP task scheduler
MIT