plinker/cron

A cron component which allows you to read and control cron tasks on remote systems.

v3.0.4 2018-05-11 16:18 UTC

README

A cron component which allows you to read and control cron tasks on remote systems.

Install

Require this package with composer using the following command:

$ composer require plinker/cron

Client

Creating a client instance is done as follows:

<?php
require 'vendor/autoload.php';

/**
 * Initialize plinker client.
 *
 * @param string $server - URL to server listener.
 * @param string $config - server secret, and/or a additional component data
 */
$client = new \Plinker\Core\Client(
    'http://example.com/server.php',
    [
        'secret' => 'a secret password',
        // optional
        'config' => [
            'journal' => './.plinker/crontab.journal',
            'apply'   => false
        ]
    ]
);

// or using global function, with optional array
$client = plinker_client('http://example.com/server.php', 'a secret password', [
    'config' => [
        'journal' => './.plinker/crontab.journal',
        'apply'   => false
    ]
]);

Component Config

Methods

Once setup, you call the class though its namespace to its method.

User

Get current user, helps to debug which user the crontab is owned by.

Call

$result = $client->cron->user();

Response

www-data

Crontab

Get current crontab, equivalent to crontab -l.

Call

$result = $client->cron->crontab();

Response

# My Cron Task
0 * * * * cd ~
# \My Cron Task

Dump

Get current crontab journal. The journal is a file which gets built and then applied to the real crontab.

Call

$result = $client->cron->dump();

Response

# My Cron Task
0 * * * * cd ~
# \My Cron Task

Create

Create a crontask entry. Note one entry per key, multiple calls with same key would simply update.

Call

$result = $client->cron->create('My Cron Task', '* * * * * cd ~');

Response


Get

Get a crontask entry, also has an alias method read.

Call

$result = $client->cron->get('My Cron Task');

Response

0 * * * * cd ~

Update

Update cron task.

Call

$result = $client->cron->update('My Cron Task', '0 * * * * cd ~');

Response


Delete

Delete a cron task.

Call

$result = $client->cron->delete('My Cron Task');

Response


Drop

Drop cron task journal (delete all, but does not apply it).

Call

$result =  $client->cron->drop();

Response


Apply

Apply crontab journal to users crontab.

Call

$result = $client->cron->apply();

Response


Testing

There are no tests setup for this component.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please contact me via https://cherone.co.uk instead of using the issue tracker.

Credits

Development Encouragement

If you use this project and make money from it or want to show your appreciation, please feel free to make a donation https://www.paypal.me/lcherone, thanks.

Sponsors

Get your company or name listed throughout the documentation and on each github repository, contact me at https://cherone.co.uk for further details.

License

The MIT License (MIT). Please see License File for more information.

See the organisations page for additional components.