You are not logged in.

#1 2016-05-01 19:29:35

nmiculinic
Member
Registered: 2015-12-25
Posts: 63

Systemd -- "pause" service while another is running

My situation is as follows:
* asd.service is system service
* psd.service is user mode systemd service
Both do some symbolic link/tmpfs trickery to spped up loading of certain folders in my home dir.

Next I want to make new service which is going to perform home dir backup. And that service conflicts with both of them; Can I somehow stop those services if running, run backup.service and start those services again after finishing?

Offline

#2 2016-05-01 19:56:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Systemd -- "pause" service while another is running

Are you really asking just how to stop and start a service?

systemctl stop <whatever>
rsync <whatever-else>
systemctl start <whatever>


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2016-05-02 11:27:08

nmiculinic
Member
Registered: 2015-12-25
Posts: 63

Re: Systemd -- "pause" service while another is running

Kinda,

I am asking can I do it within service file or I have to make script for it.

Offline

#4 2016-05-02 11:35:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Systemd -- "pause" service while another is running

Ah, sorry that is a good question.  I don't know of any way of doing this in the service file itself.  I presume your backup service though must call a script, right?  I'd just put the stop/start at the top/bottom of that script.

You can use multiple exec lines that are run in order doing basically what was in my last post.  But given systemd's goals of doing as much in parallel as possible, I'm not sure if/how you could ensure the proper complete shutdown of asd/psd before the backup command was also exec'ed.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-05-02 14:18:05

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Systemd -- "pause" service while another is running

You could try some combination of Conflicts= and Restart=always. Untested though so I'm not actually sure that would work.

Scott

Offline

Board footer

Powered by FluxBB