When working with systemd units, you often want to override or tweak an existing unit file without rewriting it entirely. That's where drop-in overrides come in.
But there's a subtle behavior many people miss: not all parameters behave the same way when overridden! Some get completely replaced; others accumulate values.
This article explains this behavior, especially for those dealing with .timer
or .service
files.
🔍 What are drop-in overrides?
A drop-in override is an additional configuration file placed under /etc/systemd/system/<unit>.d/*.conf
that supplements or overrides the main unit definition.
For example:
/etc/systemd/system/pkgfile-update.timer.d/override.conf
Contents:
[Timer]
OnCalendar=weekly
It lets you modify behavior without touching /usr/lib/systemd/system/pkgfile-update.timer
.
Another way to do this is to run:
sudo systemctl edit unit --drop-in=drop_in_name
This opens the file /etc/systemd/system/unit.d/drop_in_name.conf
in your text editor (creating it if necessary) and automatically reloads the unit when you are done editing. Omitting --drop-in=
option will result in systemd using the default file name override.conf.
But here's the catch: OnCalendar
doesn't override, it adds
If the original timer file contains:
[Timer]
OnCalendar=daily
And your drop-in contains:
[Timer]
OnCalendar=weekly
Then both schedules will be active: daily
and weekly
.
This is because OnCalendar
supports multiple entries; adding a new one doesn't replace the old.
You can verify this with:
systemctl show pkgfile-update.timer | grep OnCalendar
✅ How to truly override OnCalendar
To replace existing values, you must explicitly reset the field:
[Timer]
OnCalendar=
OnCalendar=weekly
The first OnCalendar=
clears all previous values. The second sets the new one.
Then reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart pkgfile-update.timer
Key takeaway
If you override parameters in systemd drop-ins, be aware:
- Some parameters stack up (accumulate) → use an empty assignment to clear.
- Others overwrite directly.
This small difference can save hours debugging why your override didn't "take effect".
Happy systemd hacking!
Top comments (0)