最近在学习写shell脚本,脚本中需要执行多个测试工具,不巧的是,每个工具在运行过程中,都会有很多打印信息,像这样:
脚本中是这样写的:
#!/bin/sh
cd /home/ubuntu/ag/thc-tls-dos/src
chmod 777 thc-ssl-dos
./thc-ssl-dos -l 500 77.77.121.29 443 --accept (有回显)
ab -n 1000 -c 100 -f TLSv12 -r "https://77.77.121.29/prx/000/http/localh/login/v1/internal_theme/login/index.html" (有回显)
cd /home/ubuntu/ag/
chmod 777 gmab
./gmab -f GMSSL -Z ECC-SM4-GCM-SM3 -n 100000 -c 100 "https://77.77.121.29:4443/prx/000/http/localh/login/gm/internal_theme/login/index.html" (有回显)
done
那么一直有回显的话,下面ab那行就没法执行,查阅资料后发现可以加上nohup:
nohup command &>/dev/null &
这里的command不是一个特定参数,而是指你要执行的命令,哪个命令无须回显,就加上即可:
nohup ./thc-ssl-dos -l 500 77.77.121.29 443 --accept &>/dev/null &
测试一下:
查看后台的进程:
确实已经在后台运行了~