|
发表于 2012-9-2 09:34:20
|
显示全部楼层
本帖最后由 fandl 于 2012-9-2 09:38 编辑
sys sch add name=pppoe-8o start-time=08:00 int=1d on-ev={/interface enable pppoe-out5}
sys sch add name=pppoe-19c start-time=19:00 int=1d on-ev={/interface disable pppoe-out5}
#添加脚本:8点开放,19点关闭。每天执行一次。
#——————用/sys scheduler pri 查看加入的 name=pppoe-8o脚本是第几个——————
#以下脚本是获取星期几
/sys sch add name=Exp_Auto start-time=07:00 interval=1d on-ev={
:local Date [/system clock get date]
:local Year ([:pick $Date 7 11]-1)
:local Month ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $Date 0 3]])
#定义本地变量 月 发现排在第几位就是几月
:local Day [:pick $Date 4 6]
:if ([:pick $Date 4 5] = 0) do={:set Day [:pick $Date 5 6]}
#如果DATE五位为零,则设Day为第六位的数值
:set Day ($Day-1)
:local leapyear 0,31,59,90,120,151,181,212,243,273,304,334,0,31,60,91,121,152,182,213,244,274,305,335
#定义闰年(能被4整除不能被100整除,能被400整除)
:global Today ($Year*365+$Year/4)
:if (($Year-$Year/4*4) != 3) do={:set Today ($Today+[:pick $leapyear $Month]+$Day)} else={:set Today ($Today+[:pick $leapyear ($Month+12)]+$Day)}
:local usname;:local uspfl;:local Ccomment;:local lc;:local rc;:local Exp;:local js;:local pcl;:local CYear;:local CMonth;:local CDay;:local CToday
#利用公元天数计算今天是星期几,0代表星期日
:global Week ($Today-$Today/7*7)
#:log info ("今天是星期" . $Week)
if $Week=(0,6) do={/sys scheduler disable 1}
#如果是星期六和星期天,就执行关闭序号1的脚本(根据查到的序号修改)
对 $Week=(0,6)不熟悉
如果不对的话,麻烦高手修改一下。
也可以如下修改
if ($Week=0) do={/sys scheduler disable 1}
if ($Week=6) do={/sys scheduler disable 1}
获取星期几的脚本根据“pppoe-提前3天通知到期踢下线-小77脚本”里的内容修改。非本人原创! |
|