【问题标题】:How can I stop python script using putty on debian server如何在 debian 服务器上使用 putty 停止 python 脚本
【发布时间】:2017-06-22 07:11:41
【问题描述】:

我运行一个 python 脚本:

python main.py

好的,它在无限 while 循环中运行。我怎样才能停止一个(实际)会话腻子?

Ctrl + c 不工作。

只关闭腻子,再次打开并杀死进程帮助我。

感谢您的帮助。

【问题讨论】:

    标签: python ssh debian putty


    【解决方案1】:

    您的代码是否使用信号模块捕获 SIGINT?或者它是通过代码中某处的 KeyboardInterrupt 捕获的(如果没有我的代码很难说)?

    您可以做的一件事是在屏幕之类的虚拟终端中启动您的进程 - 您可以通过 CTRL-A D 退出,然后在外面终止进程。

    【讨论】:

      【解决方案2】:

      试试 Ctrl + z; bg 然后杀死。

      yalca:~ farax$ python
      Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
      [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> 
      

      ctrl + z

      [1]+  Stopped                 python
      yalca:~ farax$ bg
      [1]+ python &
      
      [1]+  Stopped                 python
      yalca:~ farax$ jobs
      [1]+  Stopped                 python
      yalca:~ farax$ kill %1
      [1]+  Terminated: 15          python
      yalca:~ farax$ 
      
      1. Ctrl + z => 停止前台进程
      2. bg => 继续进程 背景
      3. kill %1 => 杀死后台进程 nr 1(由作业显示 命令)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-07
        • 1970-01-01
        • 2016-07-17
        • 2016-12-03
        • 2019-08-05
        • 2018-01-09
        • 2018-03-20
        相关资源
        最近更新 更多