可以使用tkinter制作一个cron python脚本
我在Python中制作一个简单的脚本(仅用于测试),
import tkinter as tk
root = tk.Tk()
root.mainloop()
如果我在我的终端中编写python3 kinter.py
,它只能在我的终端上写下一个void tkinter窗口。
问题随之而来的是我将同一文件放在我的crontab -e
中:
* * * * * /usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py
这并非没有显示。如果我读了cron log:
Jun 15 16:44:01 mypc_fcoterroba CRON[125245]: (fcoterroba) CMD (/usr/bin/python3 /home/francisco/Desktop/fcoterroba/personalProjects/myShit/kinter.py)
你知道我该怎么办吗?
btw :我正在使用Ubuntu 20.04 LTS
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自动答案
如果您想使用TKINTER或任何其他GUI Python库,则应指定要显示的显示(通常为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
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