3

I have a couple of services using "ExecStart=/usr/bin/java -jar" and I want them to start as late as possible (after network, firewall and login service).

I have tried to list different dependencies in [Unit] both "After" and "Requires", but it doesn't seems to do anything. If I look at the boot log my services starts before all dependencies.

I've tried (for example),

[Unit]
Description=My Service 01
Requires=network.target
After=systemd-user-sessions.service network.target

I can see that crond starts last in the boot sequence, so I've tried.

[Unit]
Description=My Service 02
After=crond.service

No difference... My services starts long before crond.

Any suggestions? Am I doing something wrong? It's the same on both Red Hat 7.2 and 7.3.

  • What does your [Install] section look like? – Patrick Apr 19 '17 at 12:42
-1

The Arch wiki sysyemd page has a bit of insight into this:

Note that Wants= and Requires= do not imply After=, meaning that if After= is not specified, the two units will be started in parallel.

For each dependency, you probably want to add both a Requires and After for each unit that you want it to start after:

[Unit] 
Description=My Service 02 
Requires=crond.service
After=crond.service
  • The asker already has After in their service file. Unless their service actually requires cron (or whatever they're starting after), they should not be making it required. – Patrick Apr 19 '17 at 18:25
  • Good point, you're right that this includes a possibly unnecessary Requires, perhaps I'll have to rethink my answer. – etskinner Apr 19 '17 at 18:52

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.