Cron job not running? Fix a crontab that silently fails

Fix a Linux or macOS crontab that silently fails, then get an alert before you discover broken backups days later.

Find the failure before your next backup is due

You want your backups to finish and a warning when they do not. Start by separating a job that never launches from a script that launches and fails. Work through this checklist on the machine that owns the schedule.

1. Check that the cron service can run

On Linux with systemd, inspect the service for your distribution. Debian and Ubuntu commonly use cron; distributions using Cronie commonly use crond. Run the matching command:

systemctl status cron
# Or, for a crond service:
systemctl status crond

If it is stopped, investigate its logs before starting it with sudo systemctl start cron (or crond). Hosts without systemd use their own service manager. Containers may not run a cron daemon at all.

On macOS, launchd manages cron. Inspect its service with sudo launchctl print system/com.vix.cron; an on-demand service need not have a persistent PID. Make sure the Mac is awake at the scheduled time: cron does not catch up runs missed during sleep or shutdown. Apple recommends launchd for new timed jobs. See Apple’s timed-job guidance.

2. Confirm the crontab was saved for the right user

whoami
crontab -l
# Edit and save this user’s crontab:
crontab -e
# Inspect root’s separate crontab:
sudo crontab -l
# Inspect a named account’s crontab:
sudo crontab -u backupuser -l

Run crontab -l again after saving. sudo crontab -e normally edits root’s jobs, with different permissions, HOME and credentials. Avoid commands that wait for a sudo password inside a job. Choose the account that can read the source and write the backup.

A user crontab entry has five time fields followed by the command. Do not add a username there. Linux /etc/crontab and /etc/cron.d entries include a user field. Use crontab -e rather than editing spool files directly; see the Debian cron manual.

3. Use absolute paths and an explicit environment

Cron’s environment is smaller than your terminal’s. Shell profiles, aliases, activated virtual environments and language version managers may be absent. Find executables with command -v in your terminal, then use their actual absolute paths. Homebrew and virtual-environment paths need particular care.

SHELL=/bin/sh
PATH=/usr/bin:/bin
0 2 * * * cd /srv/backups && /srv/backups/backup.sh >> /tmp/job.log 2>&1

Replace the paths for your host. Set required variables in the crontab or load them explicitly inside the script. Cron does not guarantee your project as its working directory. For a rough reproduction, run the command as the job’s user with a reduced environment; add only the variables it actually needs.

4. Escape percent signs and keep the final newline

In a crontab command, cron treats an unescaped % as a newline, even inside shell quotes; the rest becomes standard input. Escape literal percent signs with a backslash, or move date formatting into your script where this cron-specific escaping is unnecessary.

0 2 * * * /bin/date +\%F >> /tmp/job.log 2>&1

End the last entry with a newline. A missing trailing newline can make a crontab invalid or leave its final entry unprocessed. Save a normal Unix text file, and check for installation errors. These parsing rules are documented in Cronie’s crontab reference.

5. Check script permissions and the shebang

For direct execution, the script needs execute permission, a valid first line such as #!/bin/sh, and an installed interpreter. A Bash script should name the actual Bash path. The job’s user also needs access to parent directories and input/output files.

ls -l /srv/backups/backup.sh
head -n 1 /srv/backups/backup.sh
chmod u+x /srv/backups/backup.sh

Run the script as its cron user. Check for Windows CRLF line endings if you see a bad-interpreter error. If you explicitly invoke an interpreter, the script needs to be readable; the executable bit on the script itself is not required.

6. Match the schedule and timezone

Check date on the host and read man 5 crontab. Cronie supports CRON_TZ=Europe/Dublin above schedule entries. Other implementations, including macOS cron, should not be assumed to support it. Setting TZ for the command does not necessarily change when cron launches it.

Check daylight-saving transitions against your scheduler’s behavior. Set the CronPulse check to the same timezone and allow grace for job runtime. The cron helper can preview the expression; your host’s implementation may handle clock changes differently.

7. Capture output and inspect scheduler logs

Add >> /tmp/job.log 2>&1 to append standard output and errors to a log. The order matters: stderr follows stdout into the file. For this temporary diagnostic, make sure the cron user can write the file, then inspect it after the scheduled minute.

tail -n 100 /tmp/job.log
# Linux with systemd: choose the matching unit
sudo journalctl -u cron --since "1 hour ago"
sudo journalctl -u crond --since "1 hour ago"
# If syslog files are configured:
sudo tail -n 100 /var/log/syslog
# Some distributions use /var/log/cron instead.
# macOS unified logs:
sudo /usr/bin/log show --last 1h --predicate 'process == "cron"'

Log locations and detail vary by system. A scheduler entry proves a launch was attempted, not that the backup completed. Inspect the job’s own log for command errors. For ongoing use, choose an appropriate log path and configure rotation.

The core problem: cron can fail silently with no alert

Cron can mail command output when local mail delivery is configured. That is easy to miss or unavailable on a minimal host, and a stopped scheduler cannot send its own warning. A quiet script can also exit unsuccessfully without output. Fixing today’s crontab does not tell you when next week’s backup goes missing.

Add a heartbeat so a missing backup gets your attention

  1. Create a free CronPulse check. Match your backup’s schedule and timezone, and add grace for its expected runtime.
  2. Connect an alert channel, send a test and link it to the check. Copy the check’s private ping URL.
  3. Append a success ping with && so it runs only after the backup succeeds:
/srv/backups/backup.sh && /usr/bin/curl -fsS --retry 3 "<ping-url>"

Replace <ping-url> with your private URL and verify the curl path on your host. Here is a complete user-crontab example with a ten-second timeout per curl attempt and a log for both commands:

0 2 * * * (cd /srv/backups && /srv/backups/backup.sh && /usr/bin/curl -fsS --retry 3 -m 10 "<ping-url>") >> /tmp/job.log 2>&1

Complete one successful run and confirm the check turns up: monitoring starts after the first successful ping. If a later job fails, never starts or cannot deliver its ping, the missing success triggers an overdue alert after the expected deadline plus grace. With this success-only pattern, a nonzero exit is detected through the missing heartbeat, rather than reported immediately.

For immediate failure reporting, use the crontab exit-code wrapper, which preserves the job’s exit status and reports it to CronPulse. Test a successful run, a deliberate failure and a missed run. Deadlines are evaluated once a minute; expect alerts roughly 1–2 minutes after grace ends, subject to delivery and scheduler load. A heartbeat confirms the command reported success; still test that your backups can be restored.

Start free, or choose Lifetime Pro

The free plan includes 20 checks, three alert channels and 100 log entries per check. No card required. You can start with the backup you most want to stop checking by hand.

Lifetime Pro is €69 one-time for the life of CronPulse, limited to the first 100 licences. It includes 100 checks, unlimited alert channels and 1,000 log entries per check. VAT may apply. Prefer a subscription? Compare monthly and yearly plans on the pricing page.

Frequently asked questions

Why does my script work in a terminal but not in cron?
Cron runs with a minimal environment and does not load your interactive shell setup. Use absolute paths, set required variables explicitly and change to the directory your script expects. Test as the user who owns the crontab.
Does sudo crontab -e edit my own crontab?
It normally edits root’s crontab. Use crontab -e for your current user, and crontab -l to confirm the saved entry. A user crontab has five schedule fields followed by the command, without a username field.
Can I set CRON_TZ on Linux and macOS?
Cronie supports CRON_TZ for scheduling, but support varies by cron implementation. Do not assume macOS cron supports it. Read man 5 crontab on the host and match the CronPulse check’s timezone to the scheduler.
Will a success-only heartbeat alert when my backup fails?
After one successful ping arms monitoring, a failed job skips the success ping when connected with &&. CronPulse then alerts after the expected completion deadline plus grace. Use the exit-code wrapper in the crontab integration guide to report a nonzero exit immediately.
Can I start monitoring cron jobs for free?
Yes. Free includes 20 checks, three alert channels and 100 log entries per check, with no card required. Lifetime Pro is €69 one-time for the life of CronPulse, limited to the first 100 licences. VAT may apply.

Give your next job a heartbeat.

20 checks free. No card. Built in Ireland.

Create your first check ↗