`crontab /long/path/file` says "No such file or directory" for a file that exists: crontab cuts the path to 99 characters
On Ubuntu's cron 3.0pl1 (vixie cron), `crontab <file>` truncates the file argument to 99 characters before opening it. A longer path, common under deep temp or scratch directories, fails with "<path cut at 99 chars>: No such file or directory" and exit 1. Nothing is installed and the old crontab stays. Fix: cd into the directory and pass a short relative name, or pipe it: `crontab - < /long/path/file`.
Symptom
$ crontab /tmp/<a deep scratch directory>/long-path-test-directory-name/same.txt
/tmp/<...first 99 characters of the path...>/long-p: No such file or directory
$ echo $?
1
The file exists and is readable. The path in the error message stops mid-name, at exactly 99 characters.
Reproduction (safe: the file is identical to the current crontab)
d=/tmp/$(printf 'x%.0s' $(seq 1 100)) # any directory whose path makes the file path > 99 chars
mkdir -p "$d"; crontab -l > "$d/same.txt"
crontab "$d/same.txt"; echo "exit=$?" # -> No such file or directory, exit=1 (path cut at 99)
cp "$d/same.txt" /tmp/s.txt
crontab /tmp/s.txt; echo "exit=$?" # -> exit=0
crontab -l | diff - "$d/same.txt" && echo unchanged
Observed: a 131-character path failed, with the message showing the first 99 characters. A 98-character path to the same content succeeded.
Why
vixie cron, which Debian and Ubuntu ship as cron, copies the filename argument into a fixed buffer of MAX_FNAME (100) bytes. That leaves 99 characters plus the terminating NUL, so longer paths are silently cut and then opened.
Workarounds
cdinto the directory and use a relative name:cd "$dir" && crontab new.txt- Read from stdin instead:
crontab - < "$long_path" - Afterwards, check that it took:
crontab -l | diff - "$long_path". A failedcrontab FILEleaves the old crontab in place, so a script that ignores the exit code believes it installed a schedule it didn't.
Conditions
- cron
- 3.0pl1-184ubuntu2
- os
- Ubuntu 24.04.5 LTS
- observed
- 2026-10-08