---
title: Cron
description: Fire a heartbeat from any unix cron schedule with one wget line.
section: integrations
order: 1
---

# Cron

Any cron entry can fire a heartbeat to AgentPing with one extra line for cost attribution and missed-run alerting.

## The minimal example

```cron
0 9 * * *  /path/to/daily-summary.sh && /usr/bin/wget -qO- 'https://eu.ingest.agentping.io/v1/ping?key=ping_eu_018f3a2b9c1d7e8fa4b9c2d7e8f1a3b6&agent=daily-summary&status=ok' > /dev/null 2>&1
```

The trailing redirect keeps cron's email-on-output behaviour quiet. Drop it while debugging so you can see `OK` and any error text.

## Reporting failures

Cron swallows the exit code of every job. To turn that into a signal, fire a different heartbeat on the failure path:

```cron
0 9 * * *  /path/to/daily-summary.sh && /usr/bin/wget -qO- 'https://eu.ingest.agentping.io/v1/ping?key=ping_eu_018f3a2b9c1d7e8fa4b9c2d7e8f1a3b6&agent=daily-summary&status=ok' > /dev/null 2>&1 || /usr/bin/wget -qO- 'https://eu.ingest.agentping.io/v1/ping?key=ping_eu_018f3a2b9c1d7e8fa4b9c2d7e8f1a3b6&agent=daily-summary&status=fail' > /dev/null 2>&1
```

`&&` runs the success ping only if the script exited zero; `||` runs the failure ping only if it didn't. Both URLs target the same agent.

For long jobs, fire `start` at the top and `ok` or `fail` at the bottom; the server computes duration from the gap. See [Heartbeats](/docs/pulse/heartbeats).

## Schedule monitoring

A heartbeat that never fires is invisible by default. Set the agent's expected cron in the dashboard and [Pulse](/docs/pulse) pages you on missed runs. Use the same cron syntax in both places.

## Header-auth variant

For environments that log every URL through a proxy:

```cron
0 9 * * *  /usr/bin/curl -fsS -H "X-AgentPing-Key: ping_eu_018f3a2b9c1d7e8fa4b9c2d7e8f1a3b6" 'https://eu.ingest.agentping.io/v1/ping?agent=daily-summary&status=ok' > /dev/null 2>&1
```

`curl -fsS` is the cron-friendly invocation: fail silently on connection errors, show the body on HTTP errors, no progress meter.

:::warning
Never put a full `apk_` API key in a cron line. Use the per-agent `ping_` token. See [Authentication](/docs/api/auth).
:::
