TransWikia.com

How can I define a systemd target to start on boot or after another target

Unix & Linux Asked by Subtubes on January 5, 2022

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

2 Answers

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

Answered by Dmitry Lvov on January 5, 2022

[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.

Answered by JdeBP on January 5, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP