A
A
Artem Korolev2017-04-27 10:38:11
bash
Artem Korolev, 2017-04-27 10:38:11

How to determine the systemd service that called the bash script to be executed?

Hello, I've run into a small problem. The goal is to set the launch of a script in each of the necessary .service files for the OnFailure event, which will send a notification about the failure of a particular service through the telegram bot. But I ran into a problem, I can’t figure out how to determine in a bash script which service called this script, so that in the message from the bot I could indicate that this or that service has collapsed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xibir, 2017-04-27
@Ovalan

northernlightlabs.se/systemd.status.mail.on.unit.f...

A
Anton Shvets, 2017-04-27
@Xuxicheta

cat /proc/$$/status|grep PPid | cut -f 2
get the pid of the parent process.
I don't know about the unit yet.
And who prevents the unit from running the script and passing it the required parameter?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question