Jobs API
A cron-like service allowing you to run code periodically for a variety of use cases.
Jobs are created using the Coronium Webmin. See the Jobs Guide section for details.
Job Objects
core.job
Get a new reference to a Job object.
local job = core.job()
Returns
A new Job object to add your job code to.
Example
See the Jobs Guide section for examples.
job.run
The function that is used to run your job code.
function job.run() ... end
Example
See the Jobs Guide section for examples.
Return
When your work is done in your Job file, you must return a response to the Job Service. It can be one of the following:
job.OK
Lets the Job Service know that this job has completed successfully, and should continue to run on the next service interval.
Example
return job.OK
job.SLEEP
Lets the Job Service know that this job has completed successfully, and should not run again for another 24 hours from its last run. This return is helpful for Jobs that use Helpers
Example
return job.SLEEP
job.STOP
Lets the Job Service know that the Job should no longer run until the Job Service is restarted or reloaded. Can be useful for error, or other stop conditions. This does not mark the Job deactivated (see job.EXIT
).
Example
return job.STOP
job.EXIT
Lets the Job Service know that this job should be marked as deactivated, and no longer run on service intervals. You must reactivate this Job through the Webmin to have it be included in the Job Service on future restarts or reloads.
Example
return job.EXIT
Errors
If a Job causes a critical error or the job file cannot be found, it will be removed from the current service intervals, and the Job will be marked as deactivated. The last error message recieved, if any, will be stored. You can view he last error by viewing the Job details in the Jobs section of the Webmin.
Helpers
You can use the following helpers to conditionally run your job code under specific circumstances.
job.minute
The minute based on UTC time, pass true
for local time. Should be used with the job.OK return type.
job.minute(localTime)
Returns
A minute number between 00-59.
job.hour
The numerical hour in 24 hour format in UTC, pass true
for local time. Should be used with the job.OK return type.
job.hour(localTime)
Returns
A hour number between 00-23.
job.day
The abbreviated day name based on UTC, pass true
for local time.
job.day(localTime)
Returns
One of Mon
, Tue
, Wed
, Thur
, Fri
, Sat
, or Sun
as a string.
job.dayNum
The numerical day of the week in UTC, pass true
for local time.
job.dayNum(localTime)
Returns
The current day number from 1-7 as a number. Monday is 1.
job.dayMonth
The numerical day of the month in UTC, pass true
for local time.
job.dayMonth(localTime)
Returns
A number value from 1-31.
job.weekNum
The numerical week of the year in UTC, pass true
for local time.
job.weekNum(localTime)
Returns
A number value from 00-53, with the first Monday as the first day of week one.
job.month
The abbreviated month name based on UTC, pass true
for local time.
job.month(localTime)
Returns
One of Jan
, Feb
, Mar
, Apr
, May
, Jun
, Jul
, Aug
, Sep
, Nov
, Dec
as a string.
job.monthNum
The numerical month number in UTC, pass true
for local time.
job.monthNum(localTime)
Returns
The month between 1-12 as a number.