crontab 小应用之自动关机(修正版)
时间:2009-04-02 来源:Sapien
上次介绍了用 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分钟会跳出一个对话框提醒。
像这样:
500)this.width=500;" border="0"> 哈哈,好玩儿吧!
同时用 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分钟会跳出一个对话框提醒。
像这样:
500)this.width=500;" border="0"> 哈哈,好玩儿吧!
相关阅读 更多 +
排行榜 更多 +