Bug#1101921: crontab.5: example for use of \% disappears when manpage i
From
Lupe Christoph@21:1/5 to
All on Wed Apr 2 12:40:01 2025
Package: cron
Version: 3.0pl1-162
Severity: normal
Dear Maintainer,
A new line in root's crontab led to this error mail:
/bin/sh: 1: Syntax error: Unterminated quoted string
It took a while to find the cause because the string was not reported in the mail (-> wishlist).
It is because of this line
34 2 * * * /usr/local/scripts/fsdu /var > /tmp/fsdu.$(/bin/date "+%Y%m%d-%H%M%S")
The % is an escape character that is replaced with \n by cron. We weren't aware of this,
The crontab(5) manpage has an explanation of this and an example for the use as a newline:
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
An example for the escaped % is missing. Digging deeper, we found this in /usr/share/man/man5/crontab.5.gz:
33 22 * * * expr $(date +\%s) / 60 / 60 / 24 \% 9 > /dev/null || echo Wax the floor.
The backslashes are eaten by *roff rendering. Replacing them with double backslashes yields this:
33 22 * * * expr $(date +\%s) / 60 / 60 / 24 \% 9 > /dev/null || echo Wax the floor.
I'm submitting this as severity normal because it took us a significant amount of time to analyze and work around.
-- Package-specific info:
--- EDITOR:
--- /usr/bin/editor:
/usr/bin/vim.tiny
--- /usr/bin/crontab:
-rwxr-sr-x 1 root crontab 43648 Mar 2 2023 /usr/bin/crontab
--- /var/spool/cron:
drwxr-xr-x 5 root root 1024 Mar 16 2021 /var/spool/cron
--- /var/spool/cron/crontabs:
drwx-wx--T 2 root crontab 1024 Apr 2 08:43 /var/spool/cron/crontabs
--- /etc/cron.d:
drwxr-xr-x 2 root root 4096 Mar 10 07:41 /etc/cron.d
--- /etc/cron.daily:
drwxr-xr-x 2 root root 4096 Dec 28 07:42 /etc/cron.daily
--- /etc/cron.hourly:
drwxr-xr-x 2 root root 4096 Dec 26 12:48 /etc/cron.hourly
--- /etc/cron.monthly:
drwxr-xr-x 2 root root 4096 Dec 26 12:50 /etc/cron.monthly
--- /etc/cron.weekly:
drwxr-xr-x 2 root root 4096 Dec 26 12:50 /etc/cron.weekly
-- System Information:
Debian Release: 12.10
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.1.0-32-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_O