
指定一台
主机作为信任主机,这样从这台主机登录其他机器就不需要密码了。设置信任主机: 假设有四台机器:192.168.2.1~192.168.2.4,其中192.168.2.1为信任机,那么在192.168.2.1上运行如下
命令: $.sh-keygen -t rsa //此处一路回车,生成秘钥 $scp .ssh/id_rsa.pub 192.168.2.2:~/ //把秘钥拷贝到其他远程机器 $ssh 192.168.2.2 ‘cat id_rsa.pub >>.ssh/authorized_keys’ //(远程
执行命令)在远程机器上生成认证文件 经过这几步,从192.168.2.1 ssh登陆192.168.2.2时,就不会再需要输入密码了。同样的步骤再执行3、4的极其。 文本文件hostlist可以如下 192.168.2.2 192.168.2.3 192.168.2.4 #!/bin/shdoCommand(){ hosts=`sed -n'/^[^#]/p'hostlist` for host in $hosts do echo "" echo HOST$host ssh $host "$@" done return 0 } if [ $# -lt 1 ] then echo "$0cmd" exit fi do Command "$@" echo "return from doCommand" 执行命令(记得先对doCommand.s h增加执行权限 chmod u+x doCommand.sh) ./doCommand.sh “ls -al /root/” 这样该脚本就会在每台机器上执行”ls -al /root/”这个命令,并返回结果在信任主机上。基本语法:
for i in
do;
done
1、处理文件夹下的所有文件:
for i in $(ls /public/home/fengting/demo/pan69/sort_bam)
2、简单的for循环:
for ((i=1i<=33i++))
do ngmlr -t 10 -r /public/home/fengting/database/reference/rice/IRGSP-1.0_genome.fasta -q /public/home/fengting/data/hhz/H7L$i.arrow.polish.fasta -o /public/home/fengting/data/rihhz/H7L$i.sam
评论列表(0条)