< All Topics

tool/editcron

Description

Edits an existing cron job in a given SPanel account.

Info
Have a look at the tool/createcron article as the cron syntax and parameters values/combinations are explained in depth there. Both API calls share the same syntax.

Parameters

FieldTypeRequiredDescription
tokenstringYesAuthorizing API token – check API Basics for more information.
accountuserstringYesThe SPanel user account that is being managed or viewed.
actionstringYesThe category and function being executed.
minutearrayYesThe old and new minute parameter.
hourarrayYesThe old and new hour parameter.
dayarrayYesThe old and new day parameter.
montharrayYesThe old and new month parameter.
weekdayarrayYesThe old and new weekday parameter.
commandarrayYesThe old and new command parameter.

Info
You may have already noticed that most of the parameters above are listed with an array type.

When editing an existing cron job, these parameters must include old and new value as shown in the example even if there is no change to the corresponding parameter.

Example

$endpointUrl = 'https://123.123.123.123/spanel/api.php';

$postData = [
  'token' => 'provided_auth_token',
  'accountuser' => 'spanelio',
  'action' => 'tool/editcron',
  'minute' => ['*', '*/5'],
  'hour' => ['*', '*'],
  'day' => ['*', '*'],
  'month' => ['*', '*'],
  'weekday' => ['*', '*'],
  'command' => ['/usr/bin/php -q /home/spanelio/public_html/cron.php', '/usr/bin/php -q /home/spanelio/public_html/cron.php']
];

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $endpointUrl);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
$jsonOutput = curl_exec( $ch );

You can find more information about the Endpoint URL in our API Basics article.

In the example above, the only changed parameter is “minute”. Every other parameter is passed the same as in the existing cron job. The API call will result in no changes for the existing cron job except for the “minute” parameter. It will be changed from “*” (execution every minute) to “*/5” (execution every 5 minutes).

Output

{
    "result":"success",
    "data":{
        "msg":"Your changes have been saved successfully"
    }
}
Previous tool/createcron
Next tool/delcron
Table of Contents