简体   繁体   English

Crontab - shell 脚本将无法启动 [Arch Linux]

[英]Crontab - shell script will not start [Arch Linux]

OS: Arch Linux操作系统:Arch Linux

I have been trying to run a simple shell file using cron.我一直在尝试使用 cron 运行一个简单的 shell 文件。 The contents of the shell file is as follows: shell文件内容如下:

#!/bin/sh
echo "Hello, world from a shell script!"
zenity --notification --text="Hello, world from zenity!"

Meanwhile, the contents of the crontab file is as follows:同时,crontab文件的内容如下:

#My custom backup
0 12 * * * /home/dave/myscripts/my_backup.sh

#Test
* * * * * /home/dave/myscripts/test.sh

The my_backup.sh file runs without any issues, but test.sh will not run at all. my_backup.sh 文件运行没有任何问题,但 test.sh 根本不会运行。 I own both files as user "dave"and both files are executable.我以用户“dave”的身份拥有这两个文件,并且这两个文件都是可执行的。 Strange thing is: The my_backup.sh runs without any problems but the test.sh fails to run at all.奇怪的是: my_backup.sh 运行没有任何问题,但 test.sh 根本无法运行。

I have no idea where I am going wrong, please advise.我不知道我哪里出错了,请指教。 David.大卫。

UPDATE (Monday, 31st January 2022)更新(2022 年 1 月 31 日,星期一)

Seems to be a display error as per this error message:根据此错误消息,似乎是显示错误:

(zenity:23183): Gtk-WARNING **: 11:58:01.980: cannot open display:

UPDATE更新

After much searching I found the answer: Put the following into your crontab file:经过大量搜索,我找到了答案:将以下内容放入您的 crontab 文件中:

export DISPLAY=:0 && zenity --info --text "This is a zenity crontab test." --width=250

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM