-
Notifications
You must be signed in to change notification settings - Fork 72
Recurring Jobs
Applications often run dozens of recurring jobs (aka cron jobs) for batch processing. Do you know if your jobs are running successfully or possibly exiting silently with an error? As you deploy new changes, code can break and jobs start to silently fail...
Inspeqtor will verify that a recurring job has run within a given time period. If it does not get a job notification, Inspeqtor will send an alert.
Place one or more .inq files in /etc/inspeqtor/jobs.d
like this:
check jobs
temp_cleanup happens every 5 minutes
verify-deposits happens every hour
process-credit-batches happens every day
The generic format is:
check job [with owner X]
<name> happens every [N] [minute|minutes|hour|hours|day|days]
You just need to give the job a name and the recurring time window in which it will occur.
Like services, jobs can have an owner. Use check jobs with owner <NAME>
if you want to alert someone specific. Use one INQ file per owner if you want different jobs to alert different owners.
To notify Inspeqtor that a recurring job ran, run inspeqtorctl job_done <name>
as the last step in the job. This will reset the countdown timer for that job and prevent an alert. For example, in Ruby you can do this:
job_name = "daily-bank-transfer"
output = `inspeqtorctl job_done #{job_name}`
raise "Unable to contact Inspeqtor: #{output}" if output.strip != "OK"