The right way to edit the raid-check timer

So I have two systems which each have a 32TB RAID6 array (24TB usable). The slower one takes ten hours to perform a RAID check, and I really don’t want to perform it once a week, which is what is specified in /usr/lib/systemd/system/raid-check.timer:

OnCalendar=Sun --* 01:00:00

So I could edit this entry to be once a month:

OnCalendar=Sun --1…7 01:00:00

The drawback is that this file is not marked as a config file in the mdadm package, so if that package is updated, I lose my edit.

So I could edit /etc/sysconfig/raid-check, by inserting right after the ENABLED=yes line:

(($(date +%_d) > 7)) && ENABLED=no

This has the advantage that this is a configuration file, and you would expect to find configuration information about the raid-check service here. It has the drawback, however, that it affects invocations of the raid-check service that didn’t come from the timer. It also depends on an interaction with the system raid-check.timer, i.e. knowing that it runs at least once during the first seven days of the month.

So what I’ve done is to create my own version of /usr/lib/systemd/system/raid-check.timer, which I call /usr/lib/systemd/system/raid-check-mine.timer. I then replaced the symbolic link in /etc/systemd/system/timers.target.wants/raid-check.timer to point to my new file:

ln -sf /usr/lib/systemd/system/raid-check-mine.timer /etc/systemd/system/timers.target.wants/raid-check.timer

So this does what I want, but it has the disadvantage that it’s not self-documenting–it’s in an out-of-the-way place that one wouldn’t look at for configuration files. There’s also no guarantee that something won’t recreate the link to point back to the original timer file. On the other hand, this edit survived the upgrade from F36 to F37!

So what do you think? What is the best way to achieve what I want?

1 Like

Rather than doing this manually yourself, you probably want to systemctl enable --now raid-check-mine.timer . Don’t forget to systemctl daemon-reload in between edits of systemd services. You can also systemctl edit a service and that essentially creates a sort of overlay to prevent RPMs from overwriting your changes.

1 Like

It seems that “systemctl edit” is the right way to go, since it avoids the appearance of two timers that do approximately the same thing. It even does the “daemon-reload” for you when you are done editing. Thanks so much for your help!

2 Likes