LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 904|回复: 6

能否实现上网自动挂断

[复制链接]
发表于 2004-9-29 23:25:05 | 显示全部楼层 |阅读模式
本人使用宽带上网。有好几次关掉浏览器后,却忘记关掉ppp0,至使网费在不被察觉的情况下猛增。所以想能不能写一下小的脚本,实现上网定时挂断。我的意思是说,能否写个脚本不断检测鼠标和键盘,在10分钟之内,两者都没有做任何变化,那么自动断线。这样可以避免因忘记挂线而造成折损失。谢向
发表于 2004-9-29 23:54:38 | 显示全部楼层
可以这样试一试,写一个脚本放在后台,每隔N秒监测一次浏览器进程是否存在,如不存在,则kill掉ppp的进程,大致如下

  1. while ;;do #一个循环
  2. if ps -e|grep -q '\<浏览器名\>' 2>/dev/null ;then #如果浏览器进程存在,则
  3. sleep N秒
  4. else #否则
  5. kill -9 $(ps -e|awk '/\<ppp0\>/{print $2}') #杀掉ppp0进程,实现断线
  6. fi
  7. done
复制代码

ps:大致思路如此
发表于 2004-9-30 01:22:35 | 显示全部楼层
roppp自己有默认掉线时间的啊,,除非你选的是forever。。
发表于 2004-9-30 08:21:00 | 显示全部楼层
ropppe默认多长时间没有流量自动断线,另外想知道如果又有流量了会不会自动连线?
请问这个值在具体在哪里设置?谢谢
 楼主| 发表于 2004-9-30 09:29:06 | 显示全部楼层

如果在浏览器进程存在的情况下,如何实现自动断线呢

RT。另外楼上说ropppe可以设置断线时间,那么应当怎么设呢,请指教
发表于 2004-9-30 20:02:41 | 显示全部楼层
adsl-setup后,
Welcome to the Roaring Penguin ADSL client setup.  First, I will run
some checks on your system to make sure the PPPoE client is installed
properly...

Looks good!  Now, please enter some information:

USER NAME

>>> Enter your PPPoE user name (default myDSL@163.gd):

INTERFACE

>>> Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethn, where 'n' is a number.
(default eth0):

Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped.  If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses.  You may have some problems with demand-activated links.
>>> Enter the demand value (default no):                :

就这个问题。。。
 楼主| 发表于 2004-10-2 01:16:08 | 显示全部楼层

这个好像解决不了我说的那个问题呀

RT
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表