anacron은 주간 스크립트를 실행하지 않습니다.

anacron은 주간 스크립트를 실행하지 않습니다.

/etc/anacrontab:

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1   5   cron.daily  run-parts --report /etc/cron.daily
7   10  cron.weekly run-parts --report /etc/cron.weekly
@monthly    15  cron.monthly    run-parts --report /etc/cron.monthly

/etc/cron.d/anacron:

# /etc/cron.d/anacron: crontab entries for the anacron package

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

30 7-23 * * *   root    [ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi

이는 cron이 anacron을 실행하지 않고 systemd에 맡긴다는 의미입니다. 그렇죠? 하지만 관련 시스템 타이머가 표시되지 않습니다.

$ systemctl list-timers --all
NEXT                          LEFT LAST                               PASSED UNIT                         ACTIVATES                     
Sun 2023-10-29 11:36:44 CET  17min Sun 2023-10-29 10:03:38 CET  1h 15min ago fwupd-refresh.timer          fwupd-refresh.service
Sun 2023-10-29 17:27:57 CET     6h Sat 2023-10-28 18:27:57 CEST      17h ago etckeeper.timer              etckeeper.service
Sun 2023-10-29 17:27:57 CET     6h Sat 2023-10-28 18:27:57 CEST      17h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2023-10-29 18:07:00 CET     6h Sun 2023-10-29 09:22:36 CET  1h 56min ago apt-daily.timer              apt-daily.service
Mon 2023-10-30 00:00:00 CET    12h Sun 2023-10-29 00:00:01 CEST      12h ago apt-show-versions.timer      apt-show-versions.service
Mon 2023-10-30 00:00:00 CET    12h Sun 2023-10-29 00:00:01 CEST      12h ago dpkg-db-backup.timer         dpkg-db-backup.service
Mon 2023-10-30 00:00:00 CET    12h Sun 2023-10-29 00:00:01 CEST      12h ago logrotate.timer              logrotate.service
Mon 2023-10-30 01:29:34 CET    14h Mon 2023-10-23 08:14:40 CEST            - fstrim.timer                 fstrim.service
Mon 2023-10-30 06:22:39 CET    19h Sun 2023-10-29 10:19:49 CET     59min ago man-db.timer                 man-db.service
Mon 2023-10-30 06:25:00 CET    19h Sun 2023-10-29 06:25:01 CET  4h 54min ago ntpsec-rotate-stats.timer    ntpsec-rotate-stats.service
Mon 2023-10-30 06:46:54 CET    19h Sun 2023-10-29 06:25:35 CET  4h 53min ago apt-daily-upgrade.timer      apt-daily-upgrade.service
Sun 2023-11-05 03:10:25 CET 6 days Sun 2023-10-29 03:10:49 CET        8h ago e2scrub_all.timer            e2scrub_all.service

런타임 sudo anacron -n시 실행을 트리거합니다 .

실행 후 /var/log/cron.log:

2023-10-25T16:46:45.570141+03:00 hostname anacron[704597]: Anacron 2.3 started on 2023-10-25
2023-10-25T16:46:45.578029+03:00 hostname anacron[704597]: Will run job `cron.daily'
2023-10-25T16:46:45.578146+03:00 hostname anacron[704597]: Will run job `cron.monthly'
2023-10-25T16:46:45.578220+03:00 hostname anacron[704597]: Jobs will be executed sequentially
2023-10-25T16:46:45.578716+03:00 hostname anacron[704597]: Job `cron.daily' started
2023-10-25T16:46:45.583688+03:00 hostname anacron[704605]: Updated timestamp for job `cron.daily' to 2023-10-25
2023-10-25T16:47:23.041584+03:00 hostname anacron[704597]: Job `cron.daily' terminated (mailing output)
2023-10-25T16:47:23.042011+03:00 hostname anacron[704597]: Job `cron.monthly' started
2023-10-25T16:47:23.047447+03:00 hostname anacron[705937]: Updated timestamp for job `cron.monthly' to 2023-10-25
2023-10-25T16:47:23.047590+03:00 hostname anacron[704597]: Job `cron.monthly' terminated
2023-10-25T16:47:23.055468+03:00 hostname anacron[704597]: Tried to mail output of job `cron.daily', but mailer process (/usr/sbin/sendmail) exited with status 78
2023-10-25T16:47:23.055626+03:00 hostname anacron[704597]: Normal exit (2 jobs run)

주간지가 연재되지 않는 이유는 무엇일까?


편집자: 일간 신문도 그렇게 하지 않을 겁니다. 만든 날짜hosts-block-update-daily/etc/cron.daily

#!/usr/bin/env bash
echo "start @ $(date)" >> /home/mylocaluser/hosts-update-daily.log

그리고 아무것도 기록되지 않았습니다. 아래 설명에서 언급한 것처럼 anacron을 수동으로 실행할 때만 실행됩니다.

관련 정보