I made a script that asks the user if he wants to shut down the computer in 10 minutes or wait another hour and I scheduled in cron to run each hour from 18h to 7 am. However it happened two problems: 1 - The box that asks the question does not appear 2 - It does not turn off in 10 minutes but at the time that runs the script as if I had used the now option
ideas?
The Script:
#!/bin/bash
date=`date`
usuario=`who | sed q | awk -F" " '{print $1}'`
export XAUTHORITY=/home/$usuario/.Xauthority
if zenity --question --text="Seu micro ser desligado em 10 minutos. Tudo bem?" --title="Desligar?" --ok-label="Prorrogar" --cancel-label="Pode Desligar" --timeout=300; then
echo "NAO DESLIGOU "$date >> /tmp/testes_desligar;
else
echo "DESLIGOU "$date >> /tmp/testes_desligar;
/sbin/shutdown -h +10; #already tried shutdown -h 10 but same thing happens...
fi
The CRON job (on /etc/crontab):
48 0-7,16-23 * * * root /home/myuser/shell/desliga.sh
shutdown -h +10
is accurate. Due to the fact I've not used zenity for prompts, I question the if zenity line as a possible culprit - Hopefully someone else will chime in.