上次介绍了用 crontab 来整点打铃。这回我用它来自动关机。
同时用 zenity 来打开一个关机提醒对话框。zenity 的功能是:
Display graphical dialog boxes from shell scripts
$ sudo crontab -e 添加以下内容:
30 23 * * sun,mon-thu shutdown -h now
$ crontab -e 添加以下内容:(注意,如果 text 中含有中文可能会失效)
27 23 * * sun,mon-thu
export DISPLAY=:0.0; /usr/bin/zenity --warning --text="The system will shut down in 3 minutes!" >/dev/null 2>&1
这样每周日-周四,晚上23:30系统自动关机;并且关机前3分钟会跳出一个对话框提醒。
像这样:
哈哈,好玩儿吧!
阅读(1109) | 评论(2) | 转发(0) |