我的 SOHO 服务器(运行 OpenSuSE 15.5)上有一个 MD RAID(级别 10),每周日当地时间凌晨 1:00 进行长时间检查(对于 1 TB 的网络,检查时间超过 3 小时)。由于服务器并非全天候运行,而仅在必要时运行,因此我想重新安排检查时间,以便在更合理的时候启动检查,并且可能每两周只运行一次,而不是每周运行一次。我的系统中显然不再有 Cronjobs,但systemctl
支持计划任务,RAID 检查就是其中之一:
╭─root@valen ~
╰─➤ sudo systemctl list-timers mdcheck_start
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sun 2023-09-10 01:00:00 CEST 6 days left n/a n/a mdcheck_start.timer mdcheck_start.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.
我怎样才能更改计时器?
更新:显然,我还有第二个有关 MD RAID 检查的计时器:
╭─root@valen ~
╰─➤ sudo systemctl list-timers mdcheck_continue
NEXT LEFT LAST PASSED UNIT ACTIVATES
Mon 2023-09-04 01:05:00 CEST 6h left n/a n/a mdcheck_continue.timer mdcheck_continue.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.
但:该文件systemctl
仅向我提供注释:
### Editing /etc/systemd/system/mdcheck_start.timer.d/override.conf
### Anything between here and the comment below will become the new contents of the file
### Lines below this comment will be discarded
### /usr/lib/systemd/system/mdcheck_start.timer
# # This file is part of mdadm.
# #
# # mdadm is free software; you can redistribute it and/or modify it
# # under the terms of the GNU General Public License as published by
# # the Free Software Foundation; either version 2 of the License, or
# # (at your option) any later version.
#
# [Unit]
# Description=MD array scrubbing
#
# [Timer]
# OnCalendar=Sun *-*-* 1:00:00
#
# [Install]
# WantedBy= mdmonitor.service
# Also= mdcheck_continue.timer
更新:在上述文件中添加这两行后:
[Timer]
OnCalendar=Sat *-*-* 23:00:00
…RAID 检查现在启动两次,所以我基本上是添加了另一次运行,而不是替换旧运行。为什么?
答案1
好的,显然我找到了解决方案:首先,我必须停止两个计时器,如下所示:
╭─root@valen ~
╰─➤ systemctl stop mdcheck_continue.timer
╭─root@valen ~
╰─➤ systemctl stop mdcheck_start.timer
然后我编辑了两个override.conf
文件:
╭─root@valen ~
╰─➤ nano /etc/systemd/system/mdcheck_start.timer.d/override.conf
╭─root@valen ~
╰─➤ nano /etc/systemd/system/mdcheck_continue.timer.d/override.conf
…如下:
GNU nano 7.2 /etc/systemd/system/mdcheck_start.timer.d/override.conf
[Timer]
OnCalendar=Sun *-*-* 00:00:00
GNU nano 7.2 /etc/systemd/system/mdcheck_continue.timer.d/override.conf
[Timer]
OnCalendar=Sun *-*-* 00:05:00
之后,我当然执行了daemon-reload
并重新启动了两个计时器。结果:
╭─root@valen ~
╰─➤ systemctl list-timers mdcheck_start
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sun 2023-10-01 00:00:00 CEST 2 days left n/a n/a mdcheck_start.timer mdcheck_start.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.
╭─root@valen ~
╰─➤ systemctl list-timers mdcheck_continue
NEXT LEFT LAST PASSED UNIT ACTIVATES
Fri 2023-09-29 01:05:00 CEST 2h 15min left n/a n/a mdcheck_continue.timer mdcheck_continue.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.