首先touch一个空的后缀为.pid的空文件
例如:
touch /myServices/pids/access_to_lending_rates.pid
然后我们可以在使用如下shell来结束该进程(空文件不会结束任何进程)
# 然后我们可以在使用如下shell来结束该进程(空文件不会结束任何进程)
kill `cat /myServices/pids/access_to_lending_rates.pid`
使用如下命令 来将nohup启动的进程的pid写入到该空pid文件中
# 使用如下命令 来将nohup启动的进程的pid写入到该空pid文件中
nohup python37 -u /myServices/flaskServe/access_to_lending_rates.py >> /home/logs/flask/flaskServe/access_to_lending_rates.py.log 2>&1 & echo $! > /myServices/pids/access_to_lending_rates.pid
完整shell代码
kill `cat /myServices/pids/access_to_lending_rates.pid`
nohup python37 -u /myServices/flaskServe/access_to_lending_rates.py >> /home/logs/flask/flaskServe/access_to_lending_rates.py.log 2>&1 & echo $! > /myServices/pids/access_to_lending_rates.pid
例子图: