Bug#1051805: systemd-cron: shell redirect not working in crontab entries
John Flinchbaugh
john at nucleus.hjsoft.com
Tue Sep 12 19:59:54 BST 2023
Package: systemd-cron
Version: 2.1.2-1
Severity: normal
Dear Maintainer,
I can put a simple command with a redirect to a file or /dev/null, and
systemd-cron continues to email the output of the command. See the
following excerpt from the email, which shows the command I'm running:
----
Process: 3729378 ExecStart=/bin/sh /run/systemd/generator/cron-john-john-3.sh (code=exited, status=0/SUCCESS)
Main PID: 3729378 (code=exited, status=0/SUCCESS)
CPU: 28ms
2023-09-12T18:44:00+0000 nucleus.hjsoft.com systemd[1]: Starting cron-john-john-3.service - [Cron] "* * * * * ls -la > /dev/null"...
2023-09-12T18:44:00+0000 nucleus.hjsoft.com sh[3729380]: total 80
2023-09-12T18:44:00+0000 nucleus.hjsoft.com sh[3729380]: drwxr-xr-x 18 root root 4096 Aug 31 16:21 .
2023-09-12T18:44:00+0000 nucleus.hjsoft.com sh[3729380]: drwxr-xr-x 18 root root 4096 Aug 31 16:21 ..
2023-09-12T18:44:00+0000 nucleus.hjsoft.com sh[3729380]: lrwxrwxrwx 1 root root 7 Oct 5 2022 bin -> usr/bin
2023-09-12T18:44:00+0000 nucleus.hjsoft.com sh[3729380]: drwxr-xr-x 2 root root 4096 Aug 30 2011 boot
----
I would have not expected to see the output in email.
Work-around:
I can get the redirect to work, if I change the cron entry to:
----
* * * * * bash -lc "ls -la > /dev/null"
----
-- Package-specific info:
-- output of systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Tue 2023-09-12 18:50:35 95ms ago Tue 2023-09-12 18:37:28 13min ago apt-listbugs.timer apt-listbugs.service
Tue 2023-09-12 18:51:00 24s Tue 2023-09-12 18:50:00 34s ago cron-john-john-1.timer cron-john-john-1.service
Tue 2023-09-12 18:51:00 24s Tue 2023-09-12 18:50:00 34s ago cron-john-john-3.timer cron-john-john-3.service
Tue 2023-09-12 19:00:00 9min - - cron-sendmail-smmsp-0.timer cron-sendmail-smmsp-0.service
Tue 2023-09-12 19:00:00 9min - - cron-tiger-root-0.timer cron-tiger-root-0.service
Tue 2023-09-12 19:02:00 11min - - cron-logcheck-logcheck-0.timer cron-logcheck-logcheck-0.service
Tue 2023-09-12 19:49:00 58min Tue 2023-09-12 18:49:00 1min 34s ago cron-debsecan-daemon-0.timer cron-debsecan-daemon-0.service
Wed 2023-09-13 00:00:00 5h 9min - - cron-john-john-2.timer cron-john-john-2.service
Wed 2023-09-13 00:00:00 5h 9min Tue 2023-09-12 00:00:00 18h ago logrotate.timer logrotate.service
Wed 2023-09-13 01:14:21 6h Tue 2023-09-12 03:39:18 15h ago plocate-updatedb.timer plocate-updatedb.service
Wed 2023-09-13 02:32:06 7h Tue 2023-09-12 13:52:16 4h 58min ago apt-daily.timer apt-daily.service
Wed 2023-09-13 04:00:00 9h - - cron-backup-root-0.timer cron-backup-root-0.service
Wed 2023-09-13 05:05:00 10h - - cron-john-john-0.timer cron-john-john-0.service
Wed 2023-09-13 05:06:03 10h Tue 2023-09-12 05:06:03 13h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Wed 2023-09-13 05:21:04 10h Tue 2023-09-12 05:21:04 13h ago chkrootkit.timer chkrootkit.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-aptitude.timer cron-daily-aptitude.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-checksecurity.timer cron-daily-checksecurity.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-cleanup_mqueue.timer cron-daily-cleanup_mqueue.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-find.timer cron-daily-find.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-locate.timer cron-daily-locate.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-makewhatiscron.timer cron-daily-makewhatiscron.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-rpm.timer cron-daily-rpm.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-sendmail.timer cron-daily-sendmail.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-slocate.timer cron-daily-slocate.service
Wed 2023-09-13 06:10:00 11h Tue 2023-09-12 06:10:00 - cron-daily-tripwire.timer cron-daily-tripwire.service
Wed 2023-09-13 06:30:34 11h Tue 2023-09-12 06:37:30 12h ago spamassassin-maintenance.timer spamassassin-maintenance.service
Wed 2023-09-13 06:51:10 12h Tue 2023-09-12 06:47:00 12h ago apt-daily-upgrade.timer apt-daily-upgrade.service
Wed 2023-09-13 11:38:44 16h Tue 2023-09-12 01:09:55 17h ago man-db.timer man-db.service
Sun 2023-09-17 03:10:55 4 days Sun 2023-09-10 03:11:00 2 days ago e2scrub_all.timer e2scrub_all.service
Mon 2023-09-18 00:15:00 5 days Mon 2023-09-11 00:15:00 1 day 18h ago systemd-cron-cleaner.timer systemd-cron-cleaner.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-apt-xapian-index.timer cron-weekly-apt-xapian-index.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-checksecurity.timer cron-weekly-checksecurity.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-find.timer cron-weekly-find.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-locate.timer cron-weekly-locate.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-makewhatiscron.timer cron-weekly-makewhatiscron.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-mlocate.timer cron-weekly-mlocate.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-rpm.timer cron-weekly-rpm.service
Mon 2023-09-18 06:15:00 5 days Mon 2023-09-11 06:15:00 - cron-weekly-slocate.timer cron-weekly-slocate.service
Sun 2023-10-01 06:20:00 2 weeks 4 days Fri 2023-09-01 06:20:00 - cron-monthly-000loaddelay.timer cron-monthly-000loaddelay.service
39 timers listed.
Pass --all to see loaded but inactive timers, too.
-- output of systemd-delta
-- System Information:
Debian Release: trixie/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.1.0-really26-rh25-20230427021705.xenU.x86_64 (SMP w/1 CPU thread)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages systemd-cron depends on:
ii cron-daemon-common 3.0pl1-175
ii libc6 2.37-8
ii libssl3 3.0.10-1
ii libstdc++6 13.2.0-3
ii systemd [systemd-sysusers] 254.1-3
ii systemd-sysv 254.1-3
systemd-cron recommends no packages.
Versions of packages systemd-cron suggests:
ii sendmail-bin [mail-transport-agent] 8.17.2-1
-- no debconf information
More information about the Pkg-systemd-maintainers
mailing list