简体   繁体   English

如何停止运行特定Python脚本的进程?

[英]How do i stop process running a certain Python script?

I am running two different Python scripts on a Ubuntu VPS. 我上运行Ubuntu的VPS两个不同的Python脚本。 One of them is the production version, and the other one is for testing purposes. 其中一个是生产版本,另一个是用于测试目的。

From time to time, I need to kill or restart one of them. 我不时需要杀死或重启其中一个。 However ps does not show which script does each Python process runs. 但是ps没有显示每个Python进程运行哪个脚本。

What is the conventional way to do this? 这样做的常规方法是什么?

ps -AF会给你A LL工艺(而非仅仅在当前的终端,或运行作为当前用户),在F ULL细节,包括参数。

Easiest way to keep it simple would be to create a screen for each. 最简单的方法就是为每个屏幕创建一个屏幕。 screen -S prod and screen -S test, then run the python script in the background of each and detach the screen (using ctrl +a+d) then when you need to stop one screen -r prod then kill it/restart then detach again. screen -S prod和screen -S test,然后在每个后台运行python脚本并分离屏幕(使用ctrl + a + d),然后在需要停止一个屏幕时-r prod然后终止它/重新启动然后分离再次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM