You are not logged in.

#1 2012-10-21 10:36:50

rwd
Member
Registered: 2009-02-08
Posts: 671

[solved] How to restart all services with systemd?

I had the habit of restarting all daemons after an upgrade so to make sure the newest libraries, configuration files etc were loaded. I did that with a shell script that restarted the daemons in order which they were listed in rc.conf. With systemd I could do something similar by first getting a list of running services and ordering a 'systemcrl restart  <servicename>' for each. But since systemd keeps track of dependencies I wonder if that would be the way to do it. Also I would need to filter out 'one shot' type services that are only needed on bootup.

<edit>restart instead of reload</edit>

<edit>solved it with a little script</edit>

Last edited by rwd (2012-11-27 21:02:02)

Offline

#2 2012-10-21 11:51:54

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [solved] How to restart all services with systemd?

In systemctl, you can see LOAD ACTIVE ands SUB. I'd say the one-shots have SUB=exited, the mount points have SUB=mounted and devices have SUB=plugged. The rest should be safe to reload. If you use a display manager, make sure you exclude that one as well, unless you're prepared to get logged out.

Offline

#3 2012-10-21 11:55:22

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: [solved] How to restart all services with systemd?

I think that's what systemctl snapshot does.

snapshot [NAME]
           Create a snapshot. If a snapshot name is specified, the new snapshot will be named after it. If none is specified an automatic snapshot name is generated. In either case, the snapshot name used is printed to STDOUT, unless --quiet is specified.

           A snapshot refers to a saved state of the systemd manager. It is implemented itself as a unit that is generated dynamically with this command and has dependencies on all units active at the time. At a later time the user may return to this state by using the isolate command on the snapshot unit.

           Snapshots are only useful for saving and restoring which units are running or are stopped, they do not save/restore any other state. Snapshots are dynamic and lost on reboot.

Then, isolate emergency.target or rescue target and switch to the snapshot.


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#4 2012-10-21 14:37:00

rwd
Member
Registered: 2009-02-08
Posts: 671

Re: [solved] How to restart all services with systemd?

The snapshot way seems the most safe, though somewhat unwieldy. I'll give both ways a try.

Offline

#5 2012-10-21 15:44:18

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: [solved] How to restart all services with systemd?

I guess "systemctl restart A.service B.service C.service..." should do the right thing (i.e., as long as the restarts are all done in the same transactions the ordering dependencies specified in the service files will be respected).

Offline

Board footer

Powered by FluxBB