• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Understanding Drop-in Overrides in systemd: When Parameters Accumulate vs Override

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
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!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу