You are not logged in.

#1 2017-04-24 12:31:09

Nyutag
Member
Registered: 2012-07-19
Posts: 18

[Systemd] Is it possible to start a service when another is stopping?

[Didn't find the right forum, please move it where it belong.]

I made a unit file type oneshot for my backup (with borgbackup) and everything works fine. The .timer file launch my service went I want, the backup are done and the service exit.

Now, I want to do something else after my backup are done and I was wondering if it's something possible with systemd.

AFAK, "After=foo.service" will make my service start when foo.service will be running, not when foo.service stopped. I'm I wrong?

Offline

#2 2017-04-24 12:49:38

hcjl
Member
From: berlin
Registered: 2007-06-29
Posts: 330

Re: [Systemd] Is it possible to start a service when another is stopping?

wouldn't it be easier if you invoke "what shall be done" at the end of your backup script?

Offline

#3 2017-04-24 12:51:58

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Systemd] Is it possible to start a service when another is stopping?

If your backup routine only returns after everything is done you could just use another execstart in your backup service file. If that is not an option you will have to provide more details.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#4 2017-04-24 13:06:36

Nyutag
Member
Registered: 2012-07-19
Posts: 18

Re: [Systemd] Is it possible to start a service when another is stopping?

R00KIE wrote:

If your backup routine only returns after everything is done you could just use another execstart in your backup service file. If that is not an option you will have to provide more details.

So your saying that a unit with
ExecStart=foo.sh
ExecStart=bar.sh

bar.sh will be executed when foo.sh exited?

Not what I was planning but could do the job. Thanks!

Offline

#5 2017-04-24 14:11:42

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Systemd] Is it possible to start a service when another is stopping?

Nyutag wrote:

So your saying that a unit with
ExecStart=foo.sh
ExecStart=bar.sh

bar.sh will be executed when foo.sh exited?

Yes.

There are other ways to do it, see 'man systemd.service' for what you can do with service files. Hint: you can trigger your bar.sh with a timer and make it require foo.sh but I guess that's a bit awkward since your "main" task is foo.sh.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB