< All Topics



Edits an existing cron job in a given SPanel account.

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.


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.

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.


$endpointUrl = '';

$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).


        "msg":"Your changes have been saved successfully"
Previous tool/createcron
Next tool/delcron
Table of Contents