I am new with Ubuntu. Please help me for this mentioned issue. This shaded area in attached image is my process that is running on Ubuntu 14.x version. It is python program which is reading a configuration file. When I am changing some configuration I always shut down "kill [process ID]" this process and start it. On new startup it takes new process ID.
My client is non-technical guy he/she can not kill the process with changed ID and start it. I want such utility (command) that he/she can restart the process programmatically. what ever the process ID will be.
I have tried below thing:
sudo restart scheduler.py
sudo restart python3 scheduler.py
sudo scheduler.py restart
sudo python3 scheduler.py restart
All above tries are useless. Please help me
One way to achieve what you desire is as follows:
pkill scheduler.py
python3 /path/to/scheduler.py
You can also put it in a shell script.
To stop the process:
#!/bin/bash
pkill scheduler.py
exit 0
And save it as anyname1.sh
To start the process:
#!/bin/bash
python3 /path/to/scheduler.py
exit 0
Now, save it as anyname2.sh
Then, run this command to make them executable:
chmod +x /path/to/anyname1.sh
chmod +x /path/to/anyname2.sh
So, now, all your friend needs to do is double-click on those files and then click on Run
.
EDIT: If the first script doesn't work as expected you may try this:
#!/bin/bash
kill -9 $(ps axf | grep scheduler.py | grep -v grep | awk '{print $1}')
exit 0
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments