Skip to main content

crons

Creates, updates, deletes, gets or lists a crons resource.

Overview​

Namecrons
TypeResource
Idovh.hosting_web.crons

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idintegerCron's id
commandstringCommand to execute
descriptionstringDescription field for you
emailstringEmail used to receive error log (stderr)
frequencystringFrequency (crontab format) defined for the script (minutes are ignored)
languagestringCron language (node10, node11, node12, node14, node8, node9, other, php4, php5.2, php5.3, php5.4, php5.5, php5.6, php7.0, php7.1, php7.2, php7.3, php7.4, php8.0, php8.1, php8.2, php8.3, php8.4, php8.5, python2, python3, ruby2.6)
statestringCron language (created, creating, deleting, updating)
statusstringCron status (disabled, enabled, suspended)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid, service_nameReturns the command, frequency, language, email and status of the cron job.
listselectservice_namecommand, description, email, language, x_pagination_modeReturns the IDs of the cron jobs of the hosting. Filter them by command, description, email or language.
createinsertservice_name, command, frequency, languageCreates a cron job that runs a script at a crontab frequency, and returns the task. Minutes in the frequency are ignored. Errors are sent to the email address.
updateupdateid, service_name, command, frequency, languageUpdates the command, frequency, language, email or description of the cron job. Minutes in the frequency are ignored.
deletedeleteid, service_nameDeletes the cron job and returns the task.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
idintegerId
service_namestringService name (wire: serviceName)
commandstringFilter the value of command property (like)
descriptionstringFilter the value of description property (like)
emailstringFilter the value of email property (like)
languagestringFilter the value of language property (=)
x_pagination_modestringSent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode)

SELECT examples​

Returns the command, frequency, language, email and status of the cron job.

SELECT
id,
command,
description,
email,
frequency,
language,
state,
status
FROM ovh.hosting_web.crons
WHERE id = '{{ id }}' -- required
AND service_name = '{{ service_name }}' -- required
;

INSERT examples​

Creates a cron job that runs a script at a crontab frequency, and returns the task. Minutes in the frequency are ignored. Errors are sent to the email address.

INSERT INTO ovh.hosting_web.crons (
command,
description,
email,
frequency,
language,
status,
service_name
)
SELECT
'{{ command }}' /* required */,
'{{ description }}',
'{{ email }}',
'{{ frequency }}' /* required */,
'{{ language }}' /* required */,
'{{ status }}',
'{{ service_name }}'
RETURNING
id,
object_id,
done_date,
function,
last_update,
object_type,
start_date,
status
;

UPDATE examples​

Updates the command, frequency, language, email or description of the cron job. Minutes in the frequency are ignored.

UPDATE ovh.hosting_web.crons
SET
command = '{{ command }}',
description = '{{ description }}',
email = '{{ email }}',
frequency = '{{ frequency }}',
language = '{{ language }}',
status = '{{ status }}'
WHERE
id = '{{ id }}' --required
AND service_name = '{{ service_name }}' --required
AND command = '{{ command }}' --required
AND frequency = '{{ frequency }}' --required
AND language = '{{ language }}' --required;

DELETE examples​

Deletes the cron job and returns the task.

DELETE FROM ovh.hosting_web.crons
WHERE id = '{{ id }}' --required
AND service_name = '{{ service_name }}' --required
;