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


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

  • 1
    You want Requires=. – jasonwryan Oct 23 '17 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. – Edgar Martinez Oct 23 '17 at 5:51
  • That's a full stop at the end of my comment... Your current approach is correct, by the way. – jasonwryan Oct 23 '17 at 5:54
  • You can also specify After= – Alex Austin Oct 23 '17 at 11:07
  • O man I read that comment all wrong. Thank you. – Edgar Martinez Oct 23 '17 at 13:43
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.

| improve this answer | |
  • For whatever reason this is not working on Ubuntu:16.04, I tried it. – Edgar Martinez Oct 23 '17 at 13:46
  • I tried this once more and I can confirm for sure that this does not work – Edgar Martinez Oct 23 '17 at 17:02

For example

Description=ABRT Automated Bug Reporting Tool
ExecStart=/usr/sbin/abrtd -d -s
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.