PHP code example of japseyz / laravel-schedule-monitor
1. Go to this page and download the library: Download japseyz/laravel-schedule-monitor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
japseyz / laravel-schedule-monitor example snippets
return [
/*
* The schedule monitor will log each start, finish and failure of all scheduled jobs.
* After a while the `monitored_scheduled_task_log_items` might become big.
* Here you can specify the amount of days log items should be kept.
*
* Use Laravel's pruning command to delete old `MonitoredScheduledTaskLogItem` models.
* More info: https://laravel.com/docs/9.x/eloquent#mass-assignment
*/
'delete_log_items_older_than_days' => 30,
/*
* The date format used for all dates displayed on the output of commands
* provided by this package.
*/
'date_format' => 'Y-m-d H:i:s',
'notify' => [
'email' => null,
'queue' => null,
'failed' => true,
'overdue' => true,
],
'models' => [
/*
* The model you want to use as a MonitoredScheduledTask model needs to extend the
* `JapSeyz\ScheduleMonitor\Models\MonitoredScheduledTask` Model.
*/
'monitored_scheduled_task' => JapSeyz\ScheduleMonitor\Models\MonitoredScheduledTask::class,
/*
* The model you want to use as a MonitoredScheduledTaskLogItem model needs to extend the
* `JapSeyz\ScheduleMonitor\Models\MonitoredScheduledTaskLogItem` Model.
*/
'monitored_scheduled_log_item' => JapSeyz\ScheduleMonitor\Models\MonitoredScheduledTaskLogItem::class,
],
];
// app/Console/Kernel.php
use JapSeyz\ScheduleMonitor\Models\MonitoredScheduledTaskLogItem;
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule)
{
$schedule->command('model:prune', ['--model' => MonitoredScheduledTaskLogItem::class])->daily();
}
}
// app/Console/Kernel.php
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule)
{
$schedule->command('schedule-monitor:notify-overdue')->everyFiveMinutes();
}
}
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('your-command')->daily()->monitorName('a-custom-name');
$schedule->call(fn () => 1 + 1)->hourly()->monitorName('addition-closure');
}
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('your-command')->daily()->graceTimeInMinutes(10);
}
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('your-command')->daily()->doNotMonitor();
}
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('your-command')->daily()->storeOutputInDb();
}
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('your-command')->daily()->graceTimeInMinutes(10);
}