擅长:python、mysql、java
<p>只是一个猜测,但可能<code>gsettings</code>需要您的显示服务器集,只需将您的用户crontab设置为如下所示:</p>
<pre><code>DISPLAY=:0
*/5 * * * * python3 /usr/local/cronwal/cronwal.py
</code></pre>
<p>对于错误的调用,您应该在发送给crontab的用户的电子邮件中看到一个错误,如果您配置了本地生成的发送给不合格用户的邮件(请尝试<code>echo . | mail -s testing florent</code>进行测试,但您需要安装类似<code>bsd-mailx</code>的包来进行测试),则可能会告诉您未设置显示。Cron将标准错误和输出发送给运行crontab的用户</p>
<p>所有X程序都需要知道显示服务器,以便在其上执行操作。您可以阅读X(7)手册页了解详细信息。通常,当在X中使用终端时,这个环境变量已经设置好了,但是在crontab中,您需要提供它。如果您使用的不是<code>:0</code>,那么可以在相关X环境中的shell中使用<code>printenv DISPLAY</code>进行检查(顺便说一句<code>:0</code>与<code>:0.0</code>相同)</p>