vi /root/serverkaiji.shhtml
#!/bin/bash ls /tlvnksc/ | egrep -v "^c|^f" > /root/service.list for name in $(more /root/service.list) do workhome=/tlvnksc/${name}/ workjar=${workhome}${name}.jar nohup java -jar ${workjar} > ${workhome}spring.log & done
[root@localhost ~]# cat /root/service.list
dygaeureka
dygazuul
cp serverkaiji.sh stopserverkaiji.shjava
vi stopserverkaiji.shspring
#!/bin/bash ls /tlvnksc/ | egrep -v "^c|^f" > /root/service.list for name in $(more /root/service.list) do pid=`ps -ef|grep ${name}.jar|grep -v 'grep' | awk '{print $2}'` kill -9 $pid done
chmod 700 serverkaiji.shbash
vi /usr/lib/systemd/system/jar-server.serviceide
[Unit]
Description=jar
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/root/serverkaiji.sh
[Install]
WantedBy=multi-user.targetExecStop=/root/stopserverkaiji.sh
systemctl enable jar-server.servicespa
systemctl status jar-server.servicecode
systemctl stop jar-server.service
systemctl start jar-server.service
server
參考htm
https://www.cnblogs.com/feixiablog/p/8426881.htmlblog
多目錄遍歷拷貝
vi /testlvnksc/cpxm.sh
#!/bin/bash for name in $(more /root/service.list) do /testlvnksc/fabu.sh ${name} done
vi /testlvnksc/fabu.sh
#!/bin/bash
A=$1
cp -r dygaeureka $A
sed -i 's/dygaeureka/'$A'/g' $A/deploy.sh
cat $A/deploy.sh
ls /testlvnksc/dygaeureka
vi /root/service.list
a b
https://www.bilibili.com/video/av68396271?p=2