要实现ssh s202 jps查看进程状态,就需要在环境变量目录下面创建软连接:sudo ln -s /soft/jdk/bin/jps /usr/local/bin/jps
编写xcall.sh脚本
1.touch xcall.sh //创建脚本文件
2.修改脚本权限,让所有人都能执行:chmod a+x a.sh
3.将脚本文件移动到环境变量指定的目录下面:mv xcall.sh /usr/local/bin#!/bin/bash
4.接下来写xcall.sh
echo hello world
params=$@
for (( i=201 ; i <= 204 ; i = $i+1 ));do
echo =====================s$i $params ======================
ssh s$i "$params"
done
5.接下来写xsync.sh
!/bin/bash
if [[ $# -lt 1 ]]; then echo no params ;fi
p=$1
echo p=$p
dir=dirname $p
echo dir=$dir
filename=basename $p
echo filename = $filename
cd $dir
fullpath=pwd -P .
echo fullpath = $fullpath
user=whoami
for(( i = 202 ; i <= 204 ;i = $i + 1 )) ;do
echo ===============s$i==================
rsync -lr $p ${user}@s$i:$fullpath
done ;
linux脚本后面继续更新
=======================================================