
CronTabManager
Run scripts on a schedule automatically


Run commands from an SSH console with php core/scheduler/artisan.
By default you can run commands from the console with:
php core/scheduler/artisan listTo run from the site root after SSH, create or use:
php artisan listCreate the artisan file (or copy it: cp core/scheduler/artisan.example artisan):
cat > artisan << 'EOF'
#!/usr/bin/env php
<?php
define('MODX_CRONTAB_MODE', true);
require_once __DIR__.'/core/scheduler/index.php'; // Check the path to core
$Artisan = new \Webnitros\CronTabManager\Artisan\Builder($scheduler, $argv);
$Artisan->run();
EOFphp artisan list
# Available commands:
# completion Dump the shell completion script
# demo Controller demo
# help Display help for a command
# list List commands
# command
# command:create Create a new controller.
# schedule
# schedule:list List scheduled tasks
# schedule:run Run current tasks
# schedule:work Run scheduled tasks
# support
# support:clearlogmanager Clear manager logs older than 2 monthsCreate an example controller with argument arg_name:
# --name name of the new command
php artisan command:create --name=MySuperTask
# Creates controller: CrontabControllerMySuperTask [command: php artisan mysupertask --arg_name=water]
# Controller path: /var/www/html/core/scheduler/Controllers/MySuperTask.phpUsing the example above:
php artisan mysupertask --arg_name=water
# [INFO] Hello: water <----- Our argument<?php
/**
* New command "php artisan mysupertask --arg_name=water"
*/
class CrontabControllerMySuperTask extends modCrontabController
{
protected $signature = 'mysupertask {--arg_name}'; // optional arguments
public function process()
{
$name = $this->getArgument('arg_name', 'world');
$this->info('Hello: '.$name);
}
}You can change the controller signature to my-super-task so the command is available under that name:
php artisan my-super-task --arg_name=water
# [INFO] Hello: waterCron jobs run from the commands you create; all scheduled tasks are stored in the database.
php artisan crontab:add --command=mysupertaskSee the crontab page.
Jobs that match the current time will run.
php artisan schedule:runIn the Manager you can configure crontab timing: manager