I have an sh script which runs on our server.
It is started with nohup from another script so that i can easily close session and it still runs
Main script (which will start this one) is also an sh script. And it can be executed with two parameters:
--start (will start application)
--stop (will stop it using kill PID)
But since application is started by me, none else (except root) can stop already running instance or restart it.
So i was thinking more about changing owner to nobody. Would that help it? If yes, then how can it be done?
Set up the script to shut itself down on some event, instead of running until killed. Then make the main script trigger that event at
--stop(the event can be something simple like creating a specific file, or something more complex like writing a command to a fifo that the script periodically reads). This way, other users should be able to shut the script down no matter who started it.How to do this depends on the details of your script. If it doesn’t have a loop in which it can check the shutdown condition itself, you may be able to do something like have it spawn a background process that periodically checks the condition and kills its parent pid when met.