models\Crontab
Crontab model.
- Author: Bogdan Ghervan <bogdan.ghervan@gmail.com>
- Copyright: 2014 Bogdan Ghervan
- License: http://opensource.org/licenses/Apache-2.0 Apache License 2.0
Synopsis
class Crontab
implements
IteratorAggregate,Countable
{
- // constants
- const ERROR_EMPTY = "/no crontab for .+/";
- const ERROR_SPOOL_UNREACHABLE = "/'\/var\/spool\/cron' is not a directory, bailing out/";
- const ERROR_PAM_UNREADABLE = "/You \([\w]+\) are not allowed to access to \(crontab\) because of pam configuration/";
- // members
- protected $_rawTable;
- protected array $_jobs = ;
- protected string $_lineSeparator = PHP_EOL;
- // methods
- public void __construct()
- public Job|null findByHash()
- public Crontab run()
- public Crontab add()
- public Crontab update()
- public Crontab pause()
- public Crontab resume()
- public Crontab delete()
- public Crontab save()
- protected Crontab _load()
- protected Crontab _readCrontab()
- protected Crontab _parseCrontab()
- protected Crontab _handleReadError()
- public int count()
- public ArrayIterator getIterator()
Hierarchy
Implements
Constants
Name | Value |
---|---|
ERROR_EMPTY | "/no crontab for .+/" |
ERROR_SPOOL_UNREACHABLE | "/'\/var\/spool\/cron' is not a directory, bailing out/" |
ERROR_PAM_UNREADABLE | "/You \([\w]+\) are not allowed to access to \(crontab\) because of pam configuration/" |
Members
protected
- $_jobs
—
array
Loaded list of cron jobs. - $_lineSeparator
—
string
Default line separator. - $_rawTable
—
string
Raw cron table.
Methods
protected
- _handleReadError() — Handles errors encountered while attempting to read the crontab.
- _load() — Loads system crontab.
- _parseCrontab() — Parses a crontab with commentaries. It assumes the comment for a cron job comes before the job definition.
- _readCrontab() — Reads crontab for current user.
public
- __construct() — Class constructor.
- add() — Adds given cron job to crontab.
- count() — Implementation of Countable::count.
- delete() — Deletes given job from crontab.
- findByHash() — Finds job by hash. Returns null if the job couldn't be found.
- getIterator() — Implementation of IteratorAggregate::getIterator.
- pause() — Pauses cron schedule by commenting the job in crontab.
- resume() — Resumes cron schedule by un-commenting the job in crontab.
- run() — Runs the job in background.
- save() — Saves the current user's crontab.
- update() — Updates original job definition in the raw crontab with changed data.