What's new
Shorter crontab lines
- On Linux and macOS,
cronitor syncnow writes a monitored job asCRONITOR=<key> <command>instead ofcronitor exec <key> <command>. The command stays exactly as you wrote it (#66). - Sync adds one line to the top of the crontab:
SHELL=/etc/cronitor/shell(or~/.cronitor/shellwhen sync does not run as root). That file is a small script that sync installs. For a line that starts withCRONITOR=<key>, it runscronitor exec. Every other line runs in/bin/sh, as before. If the crontab already had aSHELL=line, sync keeps that shell asCRONITOR_SHELL=and jobs keep running in it. - A
CRONITOR=<key> <command>line runs exactly likecronitor exec <key> <command>: same shell, telemetry, output and exit code. If thecronitorbinary is missing, the job still runs, without telemetry. - Lines that start with
MONITORIO=<key>work the same way. - Existing
cronitor execlines are not changed.cronitor execstill works everywhere, and it is still the way to add monitoring by hand. cronitor sync --format=shortalso convertscronitor execlines.--no-stdout,--env,--api-key,--ping-api-keyand--hostnamebecome settings on the line, for exampleCRONITOR=abc123 CRONITOR_ENV=staging CRONITOR_NO_STDOUT=1 ./backup.sh. A line with any other flag stayscronitor exec. A converted job runs the same as before (#85).cronitor sync --format=execwrites every line ascronitor execagain and gives back the crontab's originalSHELLline, or none.- Windows scheduled tasks are not changed.
- Before you uninstall CronitorCLI, run
cronitor sync --format=exec. Do not delete/etc/cronitor/shellwhile a crontab still hasSHELL=/etc/cronitor/shell. If you do, no job in that crontab runs.
Safer sync of jobs that are already monitored
- Sync now finds lines that are already wrapped when the binary has a path (
/usr/local/bin/cronitor exec) or flags before or afterexec. Before, these lines could be wrapped a second time (#65). - Sync keeps the binary path, the flags and the command of a wrapped line. Only the key changes, when the monitor's code changes.
- Fixed lines written with
--no-stdoutbeforeexec. The CLI rejected that order, so those jobs did not run. Sync now writes--no-stdoutafterexecand fixes existing lines on the next run. - Sync writes unmonitored lines back unchanged. Quotes, spaces and
%are kept. - Commands with
;,|,&&or||are quoted correctly when they are wrapped, and cron's%stdin stays outside the quotes. - Turning off monitoring in the dashboard now removes the wrapper from the line.
Other changes
cronitor execnow runs the job in the shell fromSHELLwhen it is an absolute path other than/bin/sh. WhenSHELLis/bin/shor not set, it uses bash if it exists, as before (#15). If you runcronitor execby hand from zsh or fish, it now uses that shell.- CI can run a real cron end-to-end test (
tests/real-cron.sh) on pull requests with thee2elabel. - A test checks that
cronitor dashlistsCRONITOR=andMONITORIO=lines as monitored and does not wrap them again (#84).