LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-12-2018, 12:04 PM   #1
bodqhrohro
LQ Newbie
 
Registered: Apr 2018
Location: Ukraine
Distribution: Debian GNU/Linux 10
Posts: 28

Rep: Reputation: Disabled
How to override the WantedBy directive in systemd units?


I decided to move some non-critical for my usecases long-starting services to a separate deferred target so they shoudn't delay multi-user.target and graphical.target. So I created
Code:
root@localhost:/home/bodqhrohro# cat /etc/systemd/system/post-graphical-goodies.target
[Unit]
Description=Lazy-load goodies
Wants=graphical.target
and tried to override WantedBy in chosen units to this target (systemctl edit, systemctl disable, systemctl enable). For example, for kdump-tools unit, that is wanted by multi-user.target by default, I added the following drop-in:
Code:
[Install]
WantedBy=post-graphical-goodies.target
And they seem to be overridden well: after executing systemctl reload, the following symlink in /etc/systemd/system/multi-user.target.wants/ disappears. But after reboot it appears again, and both the default target and my custom one are in WantedBy:
Code:
root@localhost:/home/bodqhrohro# systemctl show kdump-tools.service|grep WantedBy
WantedBy=multi-user.target post-graphical-goodies.target
Why? Is this directive cumulative, like ExecStart? I tried to put an empty WantedBy= line before the custom directive to reset it, but that doesn't help.
 
Old 08-12-2018, 09:05 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 14,179
Blog Entries: 24

Rep: Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836
This article may help get you started: https://www.digitalocean.com/communi...and-unit-files

Scroll down to the section about "Section Directives."
 
Old 08-13-2018, 02:59 PM   #3
bodqhrohro
LQ Newbie
 
Registered: Apr 2018
Location: Ukraine
Distribution: Debian GNU/Linux 10
Posts: 28

Original Poster
Rep: Reputation: Disabled
Huh, man systemd.unit has an inconspicuous note:

Code:
       Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as
       AssertPathExists= (or e.g.  ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one
       that is to be removed. Dependencies (After=, etc.) cannot be reset to an empty list, so dependencies can only be added in drop-ins. If
       you want to remove dependencies, you have to override the entire unit.
So I solved the problem by re-editing the units with a --full option.
 
  


Reply

Tags
systemd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Use Chkservice to Manage Systemd Units in Linux LXer Syndicated Linux News 0 04-28-2018 02:42 PM
LXer: chkservice A Tool For Managing Systemd Units From Linux Terminal LXer Syndicated Linux News 0 03-22-2018 04:38 PM
LXer: systemd: Masking units LXer Syndicated Linux News 0 11-18-2015 02:42 PM
how to install systemd units in BLFS Carl_cj Linux From Scratch 4 09-24-2014 06:10 AM
I can see shared units on Windows boxes, but can't see any files within these units emiliofil Linux - Networking 2 01-24-2005 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 12:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration