3

I would like to know how I can define in a unit file for a systemd target i.e. /etc/systemd/system/sample.target

that it should be run at the multi-user.target level.

In a unit file for a service I might do something like this

[Install]
WantedBy=multi-user.target

In a target this would clearly not work so I am wondering how I could define this for a target.

I would like to create a target that runs as if it is WantedBy=multi-user.target

5
  • 1
    You want Requires=.
    – jasonwryan
    Oct 23, 2017 at 5:45
  • what does the .- mean in this context. I know that - means ignore the error, so just curious what the dot does. Also My current work around is to put my target in the /etc/systemd/system/multi-user.target.wants/ directory.
    – Subtubes
    Oct 23, 2017 at 5:51
  • 1
    That's a full stop at the end of my comment... Your current approach is correct, by the way.
    – jasonwryan
    Oct 23, 2017 at 5:54
  • You can also specify After= Oct 23, 2017 at 11:07
  • O man I read that comment all wrong. Thank you.
    – Subtubes
    Oct 23, 2017 at 13:43

2 Answers 2

1
[Install]
WantedBy=multi-user.target
In a target this would clearly not work

It works just fine for targets such as remote-fs.target; and the systemd.target manual page is clear that the [Install] section is valid in target units. So use it.

2
  • For whatever reason this is not working on Ubuntu:16.04, I tried it.
    – Subtubes
    Oct 23, 2017 at 13:46
  • I tried this once more and I can confirm for sure that this does not work
    – Subtubes
    Oct 23, 2017 at 17:02
0

For example

[Unit]
Description=ABRT Automated Bug Reporting Tool
After=syslog.target
[Service]
Type=dbus
BusName=com.redhat.abrt
ExecStart=/usr/sbin/abrtd -d -s
[Install]
WantedBy=multi-user.target

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .