Waseem Akram Malik
Waseem Akram Malik

Reputation: 587

What is the difference between "systemctl restart" and "systemctl start"?

I have two services A and B, where A is dependent on B, which means A needs services provided by B. So in A's service unit I have After and Requires set to B.

After=B.service
Requires=B.service

When I stop service B, service A also stops. After stopping B when I start it again, service A is not started and I have to start it manually.

systemctl stop B (A is also stopped)
systemctl start B (A is not started)
systemctl start A (I have to start A manually)

But if service A is already stopped and I restart service B, then both B and A are started by systemd.

systemctl stop A
systemctl restart B (B and A both are started)

What is the difference between start and restart for the kind of service unit I have for A?

Upvotes: 9

Views: 10653

Answers (2)

mad max
mad max

Reputation: 61

You can always refer man pages for better understanding. Basically wants,requires,after are treated differently.

Dependencies react differently to wants and requires in a service file.

Start is simply starting a service when you want to use it but restart is mostly done when some changes are made in service files. Refer this link for better understanding https://wiki.archlinux.org/index.php/Systemd.

Upvotes: 1

Eric.Chang
Eric.Chang

Reputation: 71

systemctl start: Used to start a service (not reboot persistent)

systemctl stop: Used to stop a service (not reboot persistent)

systemctl restart: Used to stop and then start a service

Upvotes: 2

Related Questions