Linux cron
One crontab line. The line itself exits with 0 even when the job fails, because the last curl succeeds; TaskBeacon still records the failure.
The code
This is the code the Code tab generates (with start and errors ticked). In the app it already contains your job's own address.
# crontab -e (this example runs every day at 06:00)
0 6 * * * curl -fsS -m 10 https://taskbeacon.io/ping/your-job-id/start >/dev/null; /path/to/your-job.sh; curl -fsS -m 10 "https://taskbeacon.io/ping/your-job-id/$?" >/dev/nullHow it works
The line pings /start, runs the job, then pings the address with the job's exit code at the end: /0 is OK, any other number a failure. It sends no row count and no output.
Untick options on the Code tab to leave parts out. See what can be reported.
Run on a schedule
Open your crontab with crontab -e and add the line. The first five fields are minute, hour, day of the month, month and day of the week: 0 6 * * * is every day at 06:00, 30 2 * * 1 every Monday at 02:30. Cron uses the server's time zone, TaskBeacon the time zone in your Settings: if they differ, convert the time.
Common problems
- Command not found. Cron runs with a short PATH and without your shell's settings. Use full paths, for the job and inside it.
- A % sign cuts the line. In a crontab line,
%means a new line; write\%, as the code above does. - Where is the output? Cron mails it or drops it. Add
>> /var/log/your-job.log 2>&1after the job's path to keep it. - The line exits with 0 although the job failed. The last command is the curl that reports the failure, and it succeeds; TaskBeacon still records the failure.
- No ping at all. Check that
curlis installed (curl --version) and run the curl part of the line by hand.
Use cases: Get an alert when a Python cron job or scheduled script fails · Heartbeat monitoring (a dead man's switch) for scheduled scripts · Check that last night's backup exists and isn't empty. More questions: FAQ.