Skip to content
CloseYourItdocsPages

Documentation / Using CloseYourIt

Scheduled jobs

Notice when a job that should run on its own stops running, or runs and ends badly.

A scheduled job runs on its own at intervals: a nightly backup, an email send, a cleanup. CloseYourIt does not start it. It tells you when it does not run. At every round the job says "I ran"; if it stops saying so, someone notices.

Connect a job

There is nothing to create in advance: the job shows up in the list the first time it checks in.

  1. Open Infrastructure → Crons and press Connect a job. The page has the address and the command already filled in for the project you pick.
  2. You need the project's ingest token. If you don't have one, create it from Go to the project's connection codes.
  3. Pick a short name for the job, for example nightly-backup. It is the last part of the address.
  4. Add this line at the end of your job, so it only runs once the job has reached the end:
curl -X POST https://<your-domain>/api/v1/projects/<project-id>/crons/nightly-backup/check_in \
  -H "Authorization: Bearer $CYI_TOKEN"

On the first call the job shows up in the list. There is no secret in the address: the token travels separately, in the header.

Say how often it should run

By default CloseYourIt expects a call every 60 minutes, with 5 minutes of grace. To change them, add to the call:

FieldMeaning
expected_interval_minutesevery how many minutes it should run
grace_minuteshow many minutes of delay you accept before calling it missed
namethe name shown in the list
environmentthe environment, for example production

For example, a job that runs once a day:

curl -X POST https://<your-domain>/api/v1/projects/<project-id>/crons/nightly-backup/check_in \
  -H "Authorization: Bearer $CYI_TOKEN" \
  -d 'expected_interval_minutes=1440' -d 'grace_minutes=30'

You can change interval and grace later too, with Edit on the job's page.

Say that it went wrong

If the job ran but ended badly, say so with status=fail and, if you want, the reason:

curl -X POST https://<your-domain>/api/v1/projects/<project-id>/crons/nightly-backup/check_in \
  -H "Authorization: Bearer $CYI_TOKEN" \
  -d 'status=fail' -d 'reason=Backup failed: disk full'

The job's page shows the reason next to the attempt, instead of a plain "failed". With duration_ms you can also send how long it took.

Read the status

StatusMeaning
Awaitingno call has arrived yet
OKthe last call arrived on time and went well
Missedthe call did not arrive within interval plus grace: the job did not run
Failingthe call arrived, but the job reported an error

On a job's page you find the Recent check-ins, with result, duration and reason, and the Outages: since when, how long they lasted and how many attempts.

Get alerted

When a job turns Missed the Cron missed alert goes off, if a rule covers it. New organizations already have the rule. If it is missing, the Crons page says how many jobs have no alert: press Create the rule. Or, in Alerts → Alert rules, use the Tell me if a scheduled job does not run template. See Alerts.

A Failing job shows on its page, but does not trigger an alert.

Pause or delete

Pause stops a job's checks and alerts. The history stays. Resume turns it back on.

Delete removes the job and all its history. If the job keeps calling, it comes back at the next call, with the starting settings.