Every run of a cron job logs `another run is in progress, exiting` for hours, even though `ps` shows no copy of the script running. It uses `exec 9>/run/opskit/backup.lock; flock -n 9 || exit 0`.
AdvancedTroubleshootingTroubleshooting: cron and systemd timers
Answer
Likely causes → A flock lock is held as long as any process has that file descriptor open. The script started a background or long-lived child (nohup ... &, an SSH ControlMaster, a helper daemon) that inherited fd 9, and that child is still running after the script exited.
Diagnose →
fuser -v /run/opskit/backup.lock
lsof /run/opskit/backup.lock # shows which PID holds it
ls -l /proc/<pid>/fd | grep backup.lock
Fix → Stop the holder, and close the lock fd for children that must outlive the script:
some_daemon 9>&- & # child gets no copy of fd 9
# or scope the lock to one command, so nothing else inherits it:
flock -n /run/opskit/backup.lock /opt/opskit/bin/backup.sh
Prevent → Keep lock fds away from background children, and log the holder's PID in the "already running" message (fuser output), so this is diagnosable in one step.
More on Troubleshooting: cron and systemd timers
A new job in `/etc/cron.d/opskit` never runs. Syslog shows `cron[812]: (*system*opskit) ERROR (Missing newline before EOF, this crontab file will be ignored)`.BeginnerYou copied a line from `crontab -e` into `/etc/cron.d/backup`, and syslog shows `Error: bad username; while reading /etc/cron.d/backup`. Meanwhile a teammate's user crontab mails `/bin/sh: 1: root: not found` every night.BeginnerA script works when you run it, but the cron log email says `/opt/opskit/bin/backup.sh: line 22: aws: command not found`.BeginnerThis crontab line never produces a log file, and cron mails `/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")`: `0 2 * * * /opt/backup.sh > /var/log/backup-$(date +%F).log 2>&1`IntermediateA cron job fails intermittently, but there are no emails and no logs. Syslog shows `(CRON) info (No MTA installed, discarding output)`.BeginnerA cron job that runs `docker exec -it db pg_dumpall` fails with `the input device is not a TTY`.Intermediate