控制上网时间

sh/bash/dash/ksh/zsh等Shell脚本
回复
baic
帖子: 166
注册时间: 2006-08-22 23:10

控制上网时间

#1

帖子 baic » 2008-06-28 9:44

当然前提是用户不懂pon dsl-provider
在/etc/rc.local中加入如下
$ cat /etc/rc.local

代码: 全选

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

python <<EOF
#coding:utf-8
import time,os
n=time.strftime('%k')
a=[i for i in range(8,22)]
if not int(n) in a:
    os.system('poff dsl-provider')
    print '现在不是上网时间'
EOF

at 22:30 <<EOF
poff dsl-provider
EOF
exit 0
改了点
上次由 baic 在 2008-06-28 16:01,总共编辑 3 次。
baic
帖子: 166
注册时间: 2006-08-22 23:10

#2

帖子 baic » 2008-06-28 9:47

刚写的没验证过
头像
linlee
帖子: 1132
注册时间: 2007-10-20 11:30

#3

帖子 linlee » 2008-06-28 10:12

挺好的~
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2008-06-28 10:48

这几句,怎么会要py的呢。
● 鸣学
baic
帖子: 166
注册时间: 2006-08-22 23:10

#5

帖子 baic » 2008-06-28 11:11

觉得python比较容易写一点
回复