自动登录多台远程主机查看进程是否正常
2008-01-21 11:49
337 查看
原文:http://blog.chinaunix.net/u/12442/showart_391130.html
很多时候管理员需要登录多台主机,检查进程执行是否正常。
以下脚本在HP-UX上顺利实现,估计在其他平台也没问题的,毕竟都是bash嘛,呵呵
1、脚本的实现前提条件是,所有要的远程主机的/.rhosts中包含你目前所处的本机的名字
2、创建主机列表
3、输出重定向到日志文件:当日日期.ping.log
4、同时用tail -f 来查看实时的运行结果
很多时候管理员需要登录多台主机,检查进程执行是否正常。
以下脚本在HP-UX上顺利实现,估计在其他平台也没问题的,毕竟都是bash嘛,呵呵
1、脚本的实现前提条件是,所有要的远程主机的/.rhosts中包含你目前所处的本机的名字
2、创建主机列表
3、输出重定向到日志文件:当日日期.ping.log
4、同时用tail -f 来查看实时的运行结果
#!/sbin/sh logfile=/etc/chk/log/`date +%Y%m%d`.run.log if [ -f "$logfile" ]; then rm $logfile fi touch $logfile tail -f $logfile & for i in `cat /etc/chk/hosts.run.lst` do (sleep 10;echo "ps -ef | grep run |wc -l";sleep 3;echo exit;) | rlogin $i >/etc/chk/run.tmp tail -n 3 /etc/chk/run.tmp >> $logfile done rm /etc/chk/run.tmp kill `ps -f -u root | grep "tail -f $logfile" | awk '{print $2}'` >/dev/null exit |
相关文章推荐
- shell脚本检查某个进程是否正常,如果不正常则自动启动
- shell实现ssh自动登录远程主机
- 远程登录linux,使用vi和less查看文本出现中文乱码,使用cat正常
- ssh 通过sshpass自动登录远程主机
- telnet命令来测试远程主机某端口号是否正常打开还是关闭状态
- Linux远程主机自动登录
- 如何查看windows系统是否被远程登录
- 查看主机网络是否正常的c#代码
- 远程拷贝、查看端口、vim常见快捷键、查找替换命令、grep命令、查看存储空间的命令、chkconfig命令、系统自动启动级别、主机名配置、IP地址配置、域名映射、防火墙设置
- 远程拷贝、查看端口、vim常见快捷键、查找替换命令、grep命令、查看存储空间的命令、chkconfig命令、系统自动启动级别、主机名配置、IP地址配置、域名映射、防火墙设置
- 使用expect工具 用ssh命令自动登录远程主机
- Python查看远程主机端口是否开放以及BashShell实现
- shell实现ssh自动登录远程主机
- Linux 自动登录远程主机执行命令
- putty免密码实现自动登录远程主机
- 利用telnet命令检测远程主机端口是否正常开放
- Mac下配置远程Linux 服务器SSH密钥认证自动登录
- 查看服务是否启动以及杀掉进程,再启动进程的小技巧
- 进程是否启动查看命令方法
- ssh-keygen和ssh-copy-id实现免密登录远程主机