简体   繁体   English

卡在自动运行的python程序上

[英]stuck on autorun python program

i tried to make autorun python script and my script is loop forever. 我试图使自动运行python脚本和我的脚本是永远循环。 Now i stuck on black screen, because i can't exit the python program. 现在我卡在黑屏上,因为我无法退出python程序。 I followed this tutorial http://www.raspberrypi-spy.co.uk/2013/07/running-a-python-script-at-boot-using-cron/ and in this tutorial didn't including how to exit the program. 我遵循了本教程http://www.raspberrypi-spy.co.uk/2013/07/running-a-python-script-at-boot-using-cron/,而在本教程中并未包括如何退出程序。 Can someone tell me how to stop/kill this python program? 有人可以告诉我如何停止/杀死该python程序吗? :( i want my desktop back :(我想要我的桌面回来

  1. Open a terminal (use [Ctrl][Alt][F2] to get to another TTY if you have to) 打开终端(如果需要,可以使用[Ctrl] [Alt] [F2]转到另一个TTY)
  2. Use killall to stop the offensive program. 使用killall停止攻击程序。 Example: sudo killall /home/pi/MyScript.py or sudo killall /usr/bin/python 示例: sudo killall /home/pi/MyScript.pysudo killall /usr/bin/python
  3. Remove the script from your crontab by running sudo crontab -e and removing the line from your crontab 从您的脚本crontab运行sudo crontab -e并从删除行crontab
  4. Fix your script and test it thoroughly before adding it back to your crontab. 修复脚本,并对其进行彻底测试,然后再将其添加回crontab。


If you can't kill the script with killall , you can try: 如果无法使用killall脚本,则可以尝试:

ps aux | grep /home/pi/MyScript.py

This will return a line of information about the process, it will show the owner of the process followed by a four digit process id. 这将返回有关该流程的信息,它将显示该流程的所有者,后跟一个四位数的流程ID。 You can then enter: 然后,您可以输入:

sudo kill [process id]

Also, if you used [Ctrl][Alt][F2] to get to another TTY, [Ctrl][Alt][F7] should take you back to your desktop. 另外,如果您使用[Ctrl] [Alt] [F2]转到另一个TTY,则[Ctrl] [Alt] [F7]应该带您回到桌面。

in linux or ctr+d As with the kill and killall commands, pkill is used to send signals to processes. 在linux或ctr + d中,与kill和killall命令一样,pkill用于向进程发送信号。 The pkill command allows the use of extended regular expression patterns and other matching criteria pkill命令允许使用扩展的正则表达式模式和其他匹配条件

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

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