PHP code example of byfareska / cron-bundle

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

    

byfareska / cron-bundle example snippets


final class DeleteFileEveryHourTask implements ScheduledTask {

    public function cronInvoke(DateTimeInterface $now, bool $forceRun, OutputInterface $output): bool
    {
        if($forceRun || $now->format('i') === '0'){
            $this();
            return true;
        }
        
        return false;
    }
    
    public function __invoke(): void
    {
        unlink('/var/example');
    }
}

php bin/console cron:run --task=App\\Task\\DeleteFileEveryHourTask,App\\Task\\AnotherTask

php bin/console debug:container --tag=cron.task