使用 expect 脚本自动化配置ntp 客户端
2013-01-18 16:04
281 查看
学习使用expect 工具。只是一个小脚本。ntp server配置好之后,有很多的ntp客户端服务器要配置,所以写了这个脚本,希望能提高效率。实现了,
自动化登录----->查找并注释指定行----->插入需要修改的配置----->启动ntp服务----->将ntp加入自启动列表----->查看服务状态----->查看和ntp服务器相差时间。
自动化运维道路,任重道远。
本文出自 “B612号小行星” 博客,转载请与作者联系!
自动化登录----->查找并注释指定行----->插入需要修改的配置----->启动ntp服务----->将ntp加入自启动列表----->查看服务状态----->查看和ntp服务器相差时间。
#!/usr/bin/expect spawn /usr/bin/ssh root@10.110.10.XXX expect "*password:" send "123456\r" expect "*]#" send "sed -i '/server/s/^/#/' /etc/ntp.conf\r" send "sed -i '/fudge/s/^/#/' /etc/ntp.conf\r" send "echo 'server 192.168.1.12 prefer' >> /etc/ntp.conf\r" send "ntpd -q -g\r" send " hwclock -w\r" send "/etc/init.d/ntp restart\r" send "/etc/init.d/ntp status\r" send "chkconfig ntp on\r" send "chkconfig -l ntp\r" send "netstat -unl |grep 123\r" send "ntpq -p\r" expect "*]#" send "exit\r" expect eof
自动化运维道路,任重道远。
本文出自 “B612号小行星” 博客,转载请与作者联系!
相关文章推荐
- 使用powershell脚本批量更新客户端配置文件
- 使用shell脚本自动化安装Nagios服务器端和客户端
- 使用shell脚本一键安装zabbix并配置客户端的自动发现选项
- 使用shell脚本自动化安装zabbix客户端
- 使用shell脚本自动化配置工作环境
- 使用Fabric自动化安装zabbix服务器端和客户端,附安装脚本
- 使用shell脚本实现客户端应用自动化打包——mac
- 如何使用脚本安装和配置ISA Client,并设定ISA客户端的自
- 如何使用脚本安装和配置ISA Client,并设定ISA客户端的自动侦测
- linux使用 ntpdate配置NTP客户端
- CentOS使用yum配置安装LAMP环境自动化脚本
- 实现真正的自动化,expect脚本语言使用
- rsync服务端和客户端配置自动化配置脚本
- linux下使用expect实现自动化脚本
- FastDFS的配置、部署与API使用解读(2)以字节方式上传文件的客户端代码
- ZZ 使用Jenkins配置Git+Maven的自动化构建
- 在shell脚本中使用expect实现scp传输问题
- CAS 使用 HTTPS 单向认证方式 服务端和客户端配置
- 使用visualvm远程监控JVM LINUX服务器与客户端配置方法
- ASP.NET AJAX入门系列(7):使用客户端脚本对UpdateProgress编程