问题
I want to create a simple reminder on linux at a certain time everyday. I am using crontab
to schedule running the reminder script, while in the script I am using zenity
to display a simple dialog box with a question.
In more details, I have the following script reminder.sh
:
#!/bin/bash
zenity --question --text="question?"
Then, using crontab -e
, I add the following task to run every single minute (just for testing):
* * * * * /path/to/reminder.sh
But the dialog box doesn't appear. I added some other commands to the script and I confirmed that the script runs every minute, but the dialog box still doesn't appear!
Any hints?
回答1:
I did find the solution. When I did echo
of the $DISPLAY
in the same script, it has nothing in it. So, I've set it to my machine display. But this didn't work till I added xhost +
to the script.
The final script would look like:
#!/bin/bash
xhost +
/user/bin/zenity --question --text="question?" --display="myMachine:0.0"
来源:https://stackoverflow.com/questions/21414086/schedule-a-zenity-message-on-linux