1.重启某个端口,适用于如tomcat重启8080端口,根据lsof命令查出,通过grep获取指定行,
awk获取到指定列进而得出pid值关闭即可.
pid=`lsof -i:3001|grep -v ‘PID‘|grep -w ‘(LISTEN)‘|awk ‘{print $2}‘ ` echo $pid if [ "$pid" != "" ];then kill -9 $pid echo "kill PID $pid successed!" fi
2.后台运行程序
nohup npm run start >run.log 2>&1 & exit
3.shell脚本传值
sh testsh.sh 1 testsh中通过 ‘$1‘ 取到参数, $#是个数 $*显示所有的参数.
原文地址:https://www.cnblogs.com/imaye/p/10490913.html
时间: 2024-11-01 15:41:05