1、组网需求
对 交换机 进行配置,在星期一到星期五的下午十八点关闭端口,上午八点开启GigabitEthernet1/0/1和GigabitEthernet1/0/2端口,以便起到有效节能的作用。
2、配置思路
首先查看时间,display clock,用户视图下修改时间clock dateteme 13:53:00 2025/12/26
创建关闭GigabitEthernet1/0/1、GigabitEthernet1/0/2的Job。
创建开启GigabitEthernet1/0/1、GigabitEthernet1/0/2的Job。
配置定时执行任务,使交换机在星期一到星期五的上午八点开启pc1、pc2对应的以太网端口。
配置定时执行任务,使交换机在星期一到星期五的下午十八点关闭pc1、pc2对应的以太网端口。
3、配置注意事项
通过command指定的命令行必须是设备上可成功执行的命令行,不能包括telnet、ftp、 ssh2和monitor process。由用户保证配置的正确性,否则,命令行不能自动被执行。
4、配置步骤
进入系统视图。
<Device> system-view
创建关闭GigabitEthernet1/0/1、GigabitEthernet1/0/2的Job。
[Device]scheduler job shutdown-GigabitEthernet1/0/1-2
[Device-job-shutdown-GigabitEthernet1/0/1-2]command 1 system-view
[Device-job-shutdown-GigabitEthernet1/0/1-2]command 2 interface range Gigabitethernet 1/0/1 to GigabitEthernet1/0/2
[Device-job-shutdown-GigabitEthernet1/0/1-2]command 3 shutdown
创建开启GigabitEthernet1/0/1、GigabitEthernet1/0/2的Job。
[Device]scheduler job start-GigabitEthernet1/0/1-2
[Device-job-start-GigabitEthernet1/0/1-2]command 1 system-view
[Device-job-start-GigabitEthernet1/0/1-2]command 2 interface range Gigabitethernet 1/0/1 to GigabitEthernet1/0/2
[Device-job-start-GigabitEthernet1/0/1-2]command 3 undo shutdown
配置定时执行任务,使Device在星期一到星期五的上午八点开启pc1、pc2对应的以太网端口。
[Device]scheduler schedule START-pc1/pc2
[Device-schedule-START-pc1/pc2]job start-GigabitEthernet1/0/1-2
[Device-schedule-START-pc1/pc2]time repeating at 8:00 week-day mon tue wed thu fri
[Device-schedule-START-pc1/pc2]quit
配置定时执行任务,使 Device 在星期一到星期五的下午十八点关闭pc1、pc2对应的以太网端口。
[Device]scheduler schedule STOP-pc1/pc2
[Device-schedule-STOP-pc1/pc2]job shutdown-GigabitEthernet1/0/1-2
[Device-schedule-STOP-pc1/pc2]time repeating at 18:00 week-day mon tue wed thu fri
[Device-schedule-STOP-pc1/pc2]quit
[Device-schedule-STOP-pc1/pc2]save force
附:定时重启任务
创建重启的Job。
[H3C] scheduler job reboot
[H3C-job-reboot]command 1 reboot
[H3C-job-reboot]command 2 Y
[H3C-job-reboot]quit
配置定时执行任务,使设备在每天22:30重启设备。
[H3C] scheduler schedule reboot
[H3C-schedule-reboot] job reboot
[H3C-schedule-reboot] time repeating at 22:30
[H3C-schedule-reboot] quit
[H3C]save force