Property | Type | Description | |
---|---|---|---|
$binPath | path to the 'crontab' command, for example: '/usr/bin/crontab'. Default is 'crontab' assuming 'crontab' command is available in OS shell. | ||
$defaultJobConfig | default configuration for the cron job objects. | ||
$headLines | list of lines, which should be added at the beginning of the crontab. You can put comment lines and shell configuration here. For example: php [ '# crontab created by my application', 'SHELL=/bin/sh', 'PATH=/usr/bin:/usr/sbin', ] | ||
$mergeFilter | filter, which indicates whether existing cron job should be removed on cron tab merging. Value could be a plain string, which presence in the cron job line indicates it should be removed, or a callable of following signature: boolean function (string $line), which should return true, if line should be removed. |
Method | Description | |
---|---|---|
apply ( ) : static | Applies the current {@link jobs} to the current user crontab. | |
applyFile ( string $filename ) : static | Setup the cron jobs from given file. | |
getCurrentLines ( ) : array | Returns current cron jobs setup in the system for current user. | |
getJobs ( ) : array | ||
getLines ( ) : array | Returns the crontab lines composed from [[jobs]]. | |
remove ( ) : static | Removes current [[jobs]] from the current user crontab. | |
removeAll ( ) : static | Removes all cron jobs for the current user. | |
saveToFile ( string $fileName ) : integer | Saves the current jobs into the text file. | |
setJobs ( array $jobs ) : static |
Method | Description | |
---|---|---|
applyLines ( array $lines ) | Applies given lines to current user crontab. | |
composeFileContent ( array $lines ) : string | Composes the crontab file content from given lines. | |
composeJobLine ( yii2tech\crontab\CronJob | array $job ) : string | Composes cron job line from configuration. | |
createJob ( array $config ) : yii2tech\crontab\CronJob | Creates cron job instance from its array configuration. | |
mergeLines ( array $currentLines, array $newLines ) : array | Merges existing crontab lines with new ones, applying [[mergeFilter]]. |
public apply ( ) : static | ||
return | static | self reference. |
protected applyLines ( array $lines ) | ||
$lines | array | crontab lines. |
protected composeFileContent ( array $lines ) : string | ||
$lines | array | crontab lines. |
return | string | crontab file content. |
protected composeJobLine ( yii2tech\crontab\CronJob | array $job ) : string | ||
$job | yii2tech\crontab\CronJob | array | cron job line or configuration. |
return | string | cron job line. |
public getCurrentLines ( ) : array | ||
return | array | cron job lines. |
public remove ( ) : static | ||
return | static | self reference. |
public removeAll ( ) : static | ||
return | static | self reference. |
public saveToFile ( string $fileName ) : integer | ||
$fileName | string | output file name. |
return | integer | number of written bytes. |
public $binPath |
public $defaultJobConfig |
public $headLines |
public $mergeFilter |