PHP code example of cronwatch / craft

1. Go to this page and download the library: Download cronwatch/craft 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/ */

    

cronwatch / craft example snippets



return [
    // Console commands the crontab runs, by route, with what the crontab says.
    'commands' => [
        'resave/entries' => ['schedule' => '0 3 * * *', 'timezone' => 'Europe/London'],
        'app/reports/send' => ['schedule' => '*/15 * * * *', 'grace' => '5m', 'name' => 'send-reports'],
        'app/cleanup' => true,                     // runs and failures only, no schedule
    ],
    // Queue job classes, each attempt a run.
    'queueJobs' => [
        modules\jobs\SyncInventory::class => ['failuresBeforeAlert' => 3],
    ],
];

  public function behaviors(): array
  {
      return [...parent::behaviors(), 'cronwatch' => [
          'class' => \Cronwatch\Craft\WatchCommand::class,
          'schedule' => '0 4 * * *',
      ]];
  }
  

composer t plugin/install cronwatch

*/5 * * * * cd /var/www/site && php craft cronwatch/check