PHP code example of fdevs / cron

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

    

fdevs / cron example snippets




Devs\Cron\Cron;
use FDevs\Cron\Model\Job;
use FDevs\Cron\Model\Time;
use FDevs\Cron\Model\Output;

$cron = new Cron();

$time = new Time();
$time
    ->setMinute(1)
    ->setHour(2)
    ->setDay(3)
    ->setMonth(4)
    ->setDayOfWeek(5)
    ;
    
$output = new Output();
$output
    ->setOutFile('log')
    ->setErrFile('error');
    
$job = new Job('/bin/bash command', $time, $output);

$cron
    ->addHeader(Cron::HEADER_PATH, 'path')
    ->addHeader(Cron::HEADER_HOME, 'home')
    ->addHeader(Cron::HEADER_MAILTO, '[email protected]')
    ->addHeader(Cron::HEADER_SHELL, 'shell')
    ->addHeader(Cron::HEADER_CONTENT_TYPE, 'text')
    ->addHeader(Cron::HEADER_CONTENT_TRANSFER_ENCODING, 'utf8')
    ->addJob($job)
    ;

echo strval($cron);



Devs\Cron\CrontabUpdater;
use FDevs\Cron\Cron;

$cron = new Cron();
// $cron configuration...

$cronUpdater = new CrontabUpdater('unique_key');
$cronUpdater->update($cron);