fcoterroba
fcoterroba

Reputation: 53

Can't make a cron Python script which uses Tkinter

I make a simple script (just to test) in Python which just make a void tkinter window

import tkinter as tk

root = tk.Tk()
root.mainloop()

If I write python3 kinter.py in my terminal that's works okey, without problems.

The problem came with I put this same file in my crontab -e like this:

* * * * * /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

This don't show nothing. If I read cron log:

Jun 15 16:44:01 mypc_fcoterroba CRON[125245]: (fcoterroba) CMD (/usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py)

Do you know what can I do?

BTW: I'm using Ubuntu 20.04 LTS

Upvotes: 0

Views: 182

Answers (1)

fcoterroba
fcoterroba

Reputation: 53

Auto-answer

If you want use TKinter or any other GUI Python's libraries, you should specify the display where you want to show it (which will usually be 0.0). So, In mi case, I should have put this in the cronjob:

env DISPLAY=:0.0 /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py

Upvotes: 2

Related Questions