限制电脑使用时间 失效

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
yaozhipeng
帖子: 239
注册时间: 2009-04-18 11:03

限制电脑使用时间 失效

#1

帖子 yaozhipeng » 2010-11-19 18:59

代码: 全选

#!/bin/bash

#get hour

hour=$(date +%H)

#if expression

if [ $hour -ge 8 ]&&[ $hour -lt 16 ];

then 

shutdown -h 16:00; #Shutdown when 16:00 comes

else

halt; #Shutdown now

fi
以上为代码 是否有误?
然后打开终端 输入sudo nautilus
将该文件复制到usr/local/bin/文件夹内 并设置所有者和群组都为root 访问为读写
为什么却失效??
only_one
帖子: 186
注册时间: 2010-05-25 16:49

Re: 限制电脑使用时间 失效

#2

帖子 only_one » 2010-11-19 19:28

我看脚本没问题
要自动生效应该写到 /etc/rc.local里
头像
hiphen
帖子: 803
注册时间: 2010-08-27 15:53

Re: 限制电脑使用时间 失效

#3

帖子 hiphen » 2010-11-19 20:52

如何执行此脚本的?sudo了木有? cron? 后台执行?
你没有说清
基础问题,请看入门手册http://people.ubuntu.com/~happyaron/udc-cn/lucid-html/

Acer aspire 4736G / Ubuntu 10.04LTS
Asus eeepc900 / Xandros
Nokia N900 / Maemo 1.2.12
lijiwe24
帖子: 206
注册时间: 2010-07-27 9:44

Re: 限制电脑使用时间 失效

#4

帖子 lijiwe24 » 2010-11-24 22:12

不是sudo的话,终端中貌似无法关机
ubuntu 10.10 + RedOffice + Firefox + thunderbird
回复