The script below will allow you to run gui programs from crontab
usage: * * * * /path/to/belowcode.sh "gui application"
#!/bin/bash
# Check whether the user is logged in Mate
while [ -z "$(pgrep gnome-session -n -U $UID)" ]; do
sleep 3 && count=$((count+1)) && echo "$count" > /tmp/gnome-cron.log
done
# Get the content of the Current-Desktop-Session Environment File as an array:
EnvVarList=`cat -e "/proc/$(pgrep gnome-session -n -U $UID)/environ" | sed 's/\^@/\n/g'`
# Export the Current-Desktop-Session Environment Variables:
for EnvVar in $EnvVarList; do
echo "$EnvVar" >> /tmp/gnome-cron.log
export "$EnvVar"
done
# Execute the list of the input commands
nohup "${1}" >/dev/null 2>&1 &
exit 0
then crontab -e
* * * * /home/user/run_gui_cron.sh "/usr/bin/zenity --info --text='Sit Straight'"
*/30 * * * /home/user/run_gui_cron.sh "/usr/bin/zenity --info --text='Drink water'"