PHP code example of dawn / crontab

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

    

dawn / crontab example snippets


$ composer 


rontab\CrontabManager;
$manager = CrontabManager::getInstance();
$manager->add('backup', array(
	'command' => 'ls -al',
	'schedule' => '* * * * *',
	'enable' => true,
	'output' => dirname(__FILE__) . '/log/output.log',
	'error' => dirname(__FILE__) . '/log/error.log',
));
$manager->run();

use Crontab\CrontabManager;
$manger = CrontabManager::getInstance()->get('backup');

$manager->setMinute('*/10')
		->setHour('12')
		->setDay('*')
		->setMonth('SEP')
		->setWeek('5L')
		->setCommand('cp back.php ~/index')
		->enable()
		->setOutput('/fixtures/output.txt')
		->setErrorOutput('/fixtures/error.txt')
		->run()

//get output data
$data = $manager->getData();
$error_data = $manager->getErrorData();

use Crontab\CrontabManager;

CrontabManager::getInstance()->enable('backup');
CrontabManager::getInstance()->disable('backup');

* * * * * /path/to/project && php crontab.php 1>>/dev/null 2>&1