用Ubuntu催眠
为了每天有一个充足的睡眠,请Ubuntu来提醒你,睡觉时间到,赶紧善后关机了。
嗯,其实是一个定时任务而已。

详细步骤如下:
1、打开/etc/crontab
sudo gedit /etc/crontab
2、添加如下命令(将manker替换成您的用户名)
25 23 * * 0-4 manker /usr/bin/zenity --display=:0 --warning --text="Shutdown in 5 minutes. Go to bed." 25 23 * * 0-4 root shutdown -h +5
说明:
第一部分25 23 * * 0-4,是指在星期天(day 0)~星期四(day 4),每天23:25分执行命令。参考
命令zenity功能是用Gtk+对话框显示一串提醒文字。(将manker替换成你当前使用的用户名才能正常看到)
shutdown -h +5意思就是5分钟后系统会自动关闭。

相关日志
请问为什么我的总是显示不了那个警告框呢?那个”–display”后面的”:0″是什么意思阿?两者之间有space吗?
山起山落
新设会
一月 10th, 2010 at 15:24
好像缺一个“=“号
25 23 * * 0-4 manker /usr/bin/zenity –display=:0 –warning –text=”Shutdown in 5 minutes. Go to bed.”
Reply
一月 10th, 2010 at 18:27
Sorry, but I dont speak chinese.
The –display parameter needs to be on the same display as X is currently running, which is stored in the $DISPLAY environment variable. Unfortunately this variable is not set when running from crontab, so I have just hardcoded :0. To find out where your X is running, type echo $DISPLAY and then use what is written there in the crontab.
Reply