The cronjobsusers function adds, lists and deletes cron jobs of a hosting account.
URL: https://YOUR-SERVER:2304/v1/cronjobsusers/ — permission Cronjobs Users.
| Parameter | Description |
|---|---|
user | Hosting account username |
execute | Schedule in cron format: minute hour day month weekday, for example */15 * * * * |
command | Command to run, with full paths |
URL-encode the values when you build the request (spaces, * and /), or use --data-urlencode with curl.
Add a cron job
curl -k -X POST https://203.0.113.10:2304/v1/cronjobsusers/ \
-d "key=YOUR_API_KEY&action=add&user=john" \
--data-urlencode "execute=*/15 * * * *" \
--data-urlencode "command=/usr/local/bin/php /home/john/public_html/cron.php"
{"status":"OK"}
List
curl -k -X POST https://203.0.113.10:2304/v1/cronjobsusers/ -d "key=YOUR_API_KEY&action=list&user=john"
{"status":"OK","result":["*/15 * * * * /usr/local/bin/php /home/john/public_html/cron.php\n"]}
Each entry is one line of the account’s crontab. With no jobs: {"status":"Error","result":"There are no scheduled tasks"}.
Delete
Send the same execute and command as the job to delete:
curl -k -X POST https://203.0.113.10:2304/v1/cronjobsusers/ \
-d "key=YOUR_API_KEY&action=del&user=john" \
--data-urlencode "execute=*/15 * * * *" \
--data-urlencode "command=/usr/local/bin/php /home/john/public_html/cron.php"
{"status":"OK"}
Without them: {"status":"Error","result":"All data is required"}.