Cron API
Cron jobs can be fully managed through the API and SDK. The section contains methods to execute CRUD-operations against the Cron endpoints.
#
ListReturns all cronjobs for selected environment, which is controlled by which API token that is in use.
View in API Docs
$response = $client->cron->list();if ($response->wasSuccessful()) { $items = $response->getResultItems(); // Do something with items}
#
CreateCreate a cronjob. Note that you need to specify the environment.
View in API Docs
Example:
$environmentId = 123;$response = $client->cron->create([ 'attributes' => [ 'enabled' => 1, 'command' => 'ls ./', 'comment' => 'This is a cron job created using the PHP SDK', 'schedule' => '* * * * *', 'notifications' => 'none', ]], $environmentId);if ($response->wasSuccessful()) { // Do something} elseif ($response->hasErrors()) { $errors = $response->getErrors(); // Do something with errors}
#
GetReturns a specific cronjob by ID.
View in API Docs
$response = $client->cron->get(123);if ( $response->wasSuccessful() && $item = $response->getFirstResultItem()) { // Do something echo $item->id; // 123}
#
DeleteDeletes a cronjob by ID.
View in API Docs
$response = $client->cron->delete(123);if ($response->wasSuccessful()) { // Cronjob deleted}
#
UpdateUpdated a cronjob by ID.
View in API Docs
$response = $client->cron->update(123, [ 'attributes' => [ 'comment' => 'Updated comment' ]]);if ($response->wasSuccessful()) { // Cronjob updated}