shell start / stop for python script

后端 未结 5 1070
青春惊慌失措
青春惊慌失措 2020-12-20 23:42

I have a simple python script i need to start and stop and i need to use a start.sh and stop.sh script to do it.

I have start.sh:

#!/bin/sh

scri         


        
5条回答
  •  隐瞒了意图╮
    2020-12-21 00:12

    The "correct" approach would probably be to have your script write its pid to a file in /var/run, and clear it out when you kill the script. If changing the script is not an option, have a look at start-stop-daemon.

    If you want to continue with the grep-like approach, have a look at proctools. They're built in on most GNU/Linux machines and readily available on BSD including OS X:

    pkill -f /path/to/my/script.py
    

提交回复
热议问题