How to send `SIGINT` over `systemctl` to custom daemon/service


This Content is from Stack Overflow. Question asked by mxwQuestion

I have a script that I would like to run as service on my Linux machine, let’s call it It is executable and can be run over ./path/to/

I also have script that kills, let’s call it The contents of are:


sudo kill -SIGINT $(pgrep my_script)

In essence, this should mimic Ctrl+C for

This works perfectly fine if I run the scripts from a terminal, i.e. in ttyX I run ./path/to/ to start it and in ttyY ./path/to/ to initiate the shut down sequence of

As mentioned before, the goal is to run this as deamon, so I created /etc/systemd/system/my_script.service




Using sudo systemctl start my_script.service starts the script as expected, but using sudo systemctl stop my_script.service starts the shutdown sequence for, but doesn’t let it finish… Am I missing something? The shutdown sequence takes roughly 10sec…


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?

Exit mobile version