I have packaged a Debian file of our software. Now there is a .sh
script that needs to be started to run the program/software. This .sh
script actually runs a Django server and few more services.
To actually start this application, we need to run the .desktop
file in the menu. This .desktop
file in the menu is associated with the .sh
script mentioned above. This prompts the terminal and asks for the password. Once the password is given, this will start the services and the terminal stays active.
To close this service completely, we need to kill the process by finding the PID of the process and killing it from the terminal. But now I want to kill this process when I close the terminal.
How can I do that?
If you are trying to create a service (some program that runs in the background), you should create use your system's mechanism for this. The traditional one, would be a scrip in
/etc/init.d/
, a more modern approach is to usesystemd
.E.g. a file
/etc/systemd/system/myservice.system
You can then start/stop the service (as root) using:
resp.
You can have dependency chains of services, so starting
myservice
will automatically startmyhelper1
andmyhelper2
.Checkout the manpage
systemd.unit.5