I'm trying to make a simple weekly Anacron job that backs up my computer if I click yes on the dialog. The script I wrote works fine if run manually, but when Anacron runs it, nothing happens and I see Gtk-WARNING **: cannot open display in the logs. Apparently the script is run at a stage where graphical operations cannot be run. Is there any way to get this dialog to open from an Anacron job?
Code:
#!/bin/sh
# Backs up the local filesystem on the external HDD
sleep 60
DISPLAY=:0.0
zenity --question --text "Do you want to backup? Be sure to turn on the HDD."
if [ $? -ne 0 ]
then exit 1
fi
*Do backup stuff here*
Error:
(zenity:2351): Gtk-WARNING **: cannot open display:
run-parts: /etc/cron.daily/backup-on-external exited with return code 1