OS: Arch Linux
I have been trying to run a simple shell file using cron. The contents of the shell file is as follows:
#!/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:
#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. I own both files as user "dave"and both files are executable. Strange thing is: The my_backup.sh runs without any problems but the test.sh fails to run at all.
I have no idea where I am going wrong, please advise. David.
UPDATE (Monday, 31st January 2022)
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:
export DISPLAY=:0 && zenity --info --text "This is a zenity crontab test." --width=250
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.