Docs

Quickstart

Monitor a cron job with FlatLyne in five steps, then test the alert.

This guide shows you how to add FlatLyne to an existing cron job, confirm the check turns Up, and test the alert. It uses a nightly database backup as the example.

You need a FlatLyne account. Sign in with Google; FlatLyne creates your account and a starter project the first time you sign in.

Create a check

In the dashboard, open Checks and select Create check. Fill in the form:

  • Name: a name you'll recognize in alerts, such as backup-db-nightly.
  • Schedule type: choose Simple interval to expect a ping every fixed period, or Cron expression to match your crontab line exactly.
  • Period (simple interval) or Cron expression and Timezone (cron): when the job should report in. For a backup that runs at 02:00 every night, use Cron expression with 0 2 * * * and your server's timezone.
  • Grace period: how long FlatLyne waits past the expected time before marking the check Down. Set it a little longer than the job usually takes.

A new project pre-fills a period of 1 day and a grace period of 1 hour. Select Create check. FlatLyne opens the check's page, and its status is New.

You can also use the starter check, My First Check, instead of creating a new one.

Copy the ping URL

On the check's page, find Ping endpoint and click the URL to copy it. It looks like this:

Ping URL
https://api.flatlyne.com/CSps9LOZGccsl2o7ieL0_YrQyZJtkGK_0H1u30FJ-NI

Keep the URL private

Anyone with this URL can mark your check Up or Down. Keep it out of public repositories and shared logs.

Add the ping to your crontab

Open your crontab with crontab -e and append a curl call to the job's line:

crontab
PING_URL=https://api.flatlyne.com/CSps9LOZGccsl2o7ieL0_YrQyZJtkGK_0H1u30FJ-NI
0 2 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 5 -o /dev/null "$PING_URL"

The first line sets PING_URL, a variable cron passes to the command. The && means curl only runs if backup.sh exits with status 0. If the backup fails, no ping arrives, and FlatLyne alerts you once the grace period runs out.

What each curl flag does:

  • -f makes curl exit with an error on an HTTP error response instead of treating it as success.
  • -sS hides the progress bar but still prints errors.
  • -m 10 gives up on a request after 10 seconds, so a slow network can't hang your job.
  • --retry 5 retries up to 5 times on a timeout or a temporary server error.
  • -o /dev/null discards the response body, so cron doesn't email it to you.

Send the first ping

Run the job once by hand, or call the ping URL directly from your terminal:

Terminal
curl -fsS -m 10 --retry 5 \
  https://api.flatlyne.com/CSps9LOZGccsl2o7ieL0_YrQyZJtkGK_0H1u30FJ-NI

FlatLyne replies with PONG. Reload the check's page: the status is now Up, and the ping shows up on the check's page. From now on, FlatLyne expects the next ping by the time your schedule sets.

Test an alert

Add /fail to the ping URL to report a failure:

Terminal
curl -fsS -m 10 --retry 5 \
  https://api.flatlyne.com/CSps9LOZGccsl2o7ieL0_YrQyZJtkGK_0H1u30FJ-NI/fail

The check goes Down right away, without waiting for the grace period, and FlatLyne sends an alert. By default, it emails every member of the project.

Send a normal ping to recover:

Terminal
curl -fsS -m 10 --retry 5 \
  https://api.flatlyne.com/CSps9LOZGccsl2o7ieL0_YrQyZJtkGK_0H1u30FJ-NI

The check goes back to Up, and FlatLyne sends a recovery alert.

Each check accepts up to 3 pings a minute. If you send more, FlatLyne answers with HTTP 429 and doesn't record the ping, so wait a minute before testing again.

What's next