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
Field | Type | Required | Description |
---|---|---|---|
token | string | Yes | Authorizing API token – check API Basics for more information. |
accountuser | string | Yes | The SPanel user account that is being managed or viewed. |
action | string | Yes | The category and function being executed. |
minute | array | Yes | The old and new minute parameter. |
hour | array | Yes | The old and new hour parameter. |
day | array | Yes | The old and new day parameter. |
month | array | Yes | The old and new month parameter. |
weekday | array | Yes | The old and new weekday parameter. |
command | array | Yes | The 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$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
1 2 3 4 5 6 |
{ "result":"success", "data":{ "msg":"Your changes have been saved successfully" } } |