执行脚本时阻止终端打开(crontab)

[英]prevent terminal opening while executing script (crontab)


I have written my own python script that gets .jpg's from the web and changes my desktop background. I want this to be executed periodically, so I have created a cronjob in crontab that does it. However, everytime the script is executed, an empty terminal opens for a second, which is really annoying.

我编写了自己的python脚本,从网上获取.jpg并更改我的桌面背景。我希望定期执行此操作,因此我在crontab中创建了一个cronjob来执行它。但是,每次执行脚本时,空终端都会打开一秒钟,这真的很烦人。

How do I prevent this from happening?

我该如何防止这种情况发生?

Note: I am using linux mint with mate desktop and the cronjob executes the following command:

注意:我使用linux mint和mate desktop,cronjob执行以下命令:

* * * * * /usr/bin/python /usr/share/gnome-schedule/xwrapper.py c 2 >/dev/null $

Let me know if you need further info to help.

如果您需要更多信息,请告诉我们。

Thank you very much in advance!

非常感谢你提前!

3 个解决方案

#1


0  

if you save the file as a .pyw it wont open the empty cmd when you run it i believe

如果你把文件保存为.pyw,那么当你运行它时我不会打开空的cmd我相信

#2


0  

Generally in cron you should make a script that captures your error messages. Also you may want to make the input /dev/null

通常在cron中,您应该创建一个捕获错误消息的脚本。您也可以想要输入/ dev / null

* * * * * /usr/bin/myscript

where

#!/bin/sh
/usr/bin/python /usr/share/gnome-schedule/xwrapper.py c 2 </dev/null >>/tmp/script.log 2>&1

or else try

或者试试

* * * * * /usr/bin/python /usr/share/gnome-schedule/xwrapper.py c 2 </dev/null >>/tmp/script.log 2>&1 

#3


-1  

you can use nohup as command:

你可以使用nohup作为命令:

nohup python /usr/share/gnome-schedule/xwrapper.py &
关注微信公众号

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/05/15/9a7f10d4743f24fe1827ee7c58860efd.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com