yum install expect -y
[root@localhost opt]# expect
expect1.1>
vim reboot.exp
#/usr/local/bin/expect
spawn telnet “ip地址”
expect “H3C login:”
send “用户名n”
expect “Password:”
send “密码n”
expect “”
send “rebootr”
expect “This command will reboot the system”
send “Yr”
expect eof
每天凌晨3点重启设备,并将日志记录到reboot.log
crontab -e
0 3 * * * date >> /opt/reboot.log && expect /opt/reboot.exp >> /opt/reboot.log



