Skip to main content

Schedule

The cron entries that osapi deploys. osapi dsl behavior get --name schedule and osapi dsl behavior method get show the same. Its chain shows each call that its examples make.

Behavior​

Nameschedule
DescriptionThe cron entries that osapi deploys
Placementnode
Areaconfig
Internalno
APIyes
CLIyes
Nextno
Platformsdebian
Sudonone
Runsnone
Writes/etc/cron.d/*, /etc/cron.hourly/*, /etc/cron.daily/*, /etc/cron.weekly/*, /etc/cron.monthly/*
Keeps stateno
Usesobject, managedfile
Used bynone

Methods (5)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
listreadGET/api/node/{hostname}/scheduleschedule:readList the cron entries that osapi deployed
getreadGET/api/node/{hostname}/schedule/{name}schedule:readGet one cron entry that osapi deployed
createwritePOST/api/node/{hostname}/scheduleschedule:writeDeploy a cron entry
updatewritePUT/api/node/{hostname}/schedule/{name}schedule:writeDeploy a cron entry that osapi deployed again
deletewriteDELETE/api/node/{hostname}/schedule/{name}schedule:writeRemove a cron entry that osapi deployed

Types (5)​

NAMEINPUTOUTPUT
listListInput[]Entry { name, object, schedule, interval, user, source }
getGetInput { name* }Entry { name, object, schedule, interval, user, source }
createCreateInput { name*, object*, schedule, interval, user, content_type, vars }Result { name, changed }
updateUpdateInput { name*, object, schedule, user, content_type, vars }Result { name, changed }
deleteDeleteInput { name* }Result { name, changed }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.schedule.<method>
Child spansbehavior.object.<method>, behavior.managedfile.<method>, exec chown, exec stat, file.write, file.remove, file.chmod, kv.get, kv.put
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputsname (get, create, update, delete)

Method list​

Namelist
Verbread
DescriptionList the cron entries that osapi deployed
DetailLists each file in /etc/cron.d and in /etc/cron.hourly, daily, weekly and monthly that osapi deployed, with its object, its cron expression or interval, and its user. A cron file that osapi did not deploy is not listed.
HTTPGET
Route/api/node/{hostname}/schedule
Permissionschedule:read
Commandosapi client node schedule list
Input typeListInput
Output type[]Entry

Input (0)​

None. The method takes no input; its command needs only --target.

Output (6)​

FIELDTYPEDESCRIPTION
namestringThe entry
objectstringThe object it was deployed from
schedulestringIts cron expression, for an entry in /etc/cron.d
intervalstringIts interval, for a script in /etc/cron.daily and the like
userstringThe user it runs as
sourcestringWhere its file is: cron.d, or the interval

Examples (3)​

EXAMPLEINPUTOUTPUT
An entry that osapi deployed(none)[name=osapitest, object=osapitest.cron, schedule=0 2 * * *, source=cron.d, user=root]
A daily script that osapi deployed(none)[interval=daily, name=osapitest, object=osapitest.sh, source=daily]
A host where osapi deployed none(none)

Method get​

Nameget
Verbread
DescriptionGet one cron entry that osapi deployed
DetailReads the entry from /etc/cron.d, then from each interval directory. An entry that osapi did not deploy is not found.
HTTPGET
Route/api/node/{hostname}/schedule/{name}
Permissionschedule:read
Commandosapi client node schedule get
Input typeGetInput
Output typeEntry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$, max length 64The entry, such as backup

Output (6)​

FIELDTYPEDESCRIPTION
namestringThe entry
objectstringThe object it was deployed from
schedulestringIts cron expression, for an entry in /etc/cron.d
intervalstringIts interval, for a script in /etc/cron.daily and the like
userstringThe user it runs as
sourcestringWhere its file is: cron.d, or the interval

Examples (1)​

EXAMPLEINPUTOUTPUT
An entry that osapi deployedname=osapitestname=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=root, source=cron.d

Method create​

Namecreate
Verbwrite
DescriptionDeploy a cron entry
DetailGets the object from the object store and writes it as /etc/cron.d/backup for backup, mode 0644, for a cron expression, or as /etc/cron.daily/backup, mode 0755, for a daily interval. An object of content type template, or content_type template, is rendered with the agent's facts and the vars. A file that has the content does not change. An entry of the name in a different directory does not change: move it with delete and create. A file at the path that osapi did not deploy is refused. An entry runs as its user, root included, so only admin can deploy one.
HTTPPOST
Route/api/node/{hostname}/schedule
Permissionschedule:write
Commandosapi client node schedule create
Input typeCreateInput
Output typeResult

Input (7)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$, max length 64The entry, and its file name, such as backup
objectstringyesmin length 1, max length 255The object that holds the entry, from osapi client file upload
schedulestringnoA cron expression, such as */5 * * * *; give it or interval
intervalstringnoone of hourly daily weekly monthlyThe interval of a script in /etc/cron.daily and the like; give it or schedule
userstringnopattern ^[a-z_][a-z0-9_-]*$?$The user the entry runs as
content_typestringnoone of raw templateThe content type: raw, or template to render the object with the agent's facts and vars; the object's own when empty
varsobjectnoThe vars of a template, as key=value

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe entry
changedbooleanWhether the host changed

Examples (5)​

EXAMPLEINPUTOUTPUT
An entry with a cron expressionname=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=rootname=osapitest, changed=true
A script that runs dailyname=osapitest, object=osapitest.sh, interval=dailyname=osapitest, changed=true
A template, rendered with its varsname=osapitest, object=osapitest.tmpl, schedule=0 2 * * *, content_type=template, vars=map[target:/srv]name=osapitest, changed=true
An entry that has the contentname=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=rootname=osapitest, changed=false
An entry of the name in a different directoryname=osapitest, object=osapitest.sh, interval=dailyname=osapitest, changed=false

Method update​

Nameupdate
Verbwrite
DescriptionDeploy a cron entry that osapi deployed again
DetailWrites a new object, or the entry's own, at the entry's path, with the fields that the request gives and the entry's own for the rest. A file that has the content does not change. An entry that osapi did not deploy is not found. The entry stays in its directory: an interval does not change with update.
HTTPPUT
Route/api/node/{hostname}/schedule/{name}
Permissionschedule:write
Commandosapi client node schedule update
Input typeUpdateInput
Output typeResult

Input (6)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$, max length 64The entry, such as backup
objectstringnomin length 1, max length 255The object to deploy; the entry's own when empty
schedulestringnoA new cron expression; the entry's own when empty
userstringnopattern ^[a-z_][a-z0-9_-]*$?$The user the entry runs as; the entry's own when empty
content_typestringnoone of raw templateThe content type, raw or template; the object's own when empty
varsobjectnoThe vars of a template, as key=value

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe entry
changedbooleanWhether the host changed

Examples (4)​

EXAMPLEINPUTOUTPUT
A new objectname=osapitest, object=osapitest-v2.cronname=osapitest, changed=true
A new cron expression, with the same objectname=osapitest, schedule=30 2 * * *name=osapitest, changed=true
A new object, cron expression and username=osapitest, object=osapitest-v2.cron, schedule=30 2 * * *, user=nobodyname=osapitest, changed=true
A daily script with a new objectname=osapitest, object=osapitest-v2.shname=osapitest, changed=true

Method delete​

Namedelete
Verbwrite
DescriptionRemove a cron entry that osapi deployed
DetailRemoves the entry's file and its record. An entry that osapi did not deploy does not change, and a cron file that osapi did not deploy stays.
HTTPDELETE
Route/api/node/{hostname}/schedule/{name}
Permissionschedule:write
Commandosapi client node schedule delete
Input typeDeleteInput
Output typeResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$, max length 64The entry, such as backup

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe entry
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Remove an entryname=osapitestname=osapitest, changed=true
An entry that osapi did not deployname=osapitestname=osapitest, changed=false