1
votes

I coded a simple Tkinter UI in python on my Raspberry Pi. By executing this python script the UI starts in full screen by using this code line.

Tk.attributes("-fullscreen", False)

Then I included an autostart of this script: For that reason I added the following line of code in the file "sudo nano /etc/profile"

sudo python /home/pi/myscript.py

Unfortunately, I forgot to program an "Exit-Button". Is there any way to close/kill this task?

1
alt+f4 usually works for me or sudo pkill -9 python - Joran Beasley
Beware that "pkill -9 python" might kill other instances of python, which might break something. Use "ps" to find the PID of the process you want to kill. - fonini

1 Answers

1
votes
kill $(pgrep -f myscript.py)

The -f / --full option to pgrep tells it to consider the whole command string, instead of just the binary name (python). pkill may have a similar option to avoid using a subshell, not sure.

Some other people here have suggested using the -9 flag to kill -- I wouldn't do this unless the process doesn't respond to a normal kill first.