1. Remote machine scripting:
The script name is:/app/jboss/jboss-as/logs/all_service_stop.sh
Function: Stop all apps under a directory of a server
#!/bin/bashpath=/app/jboss/jboss-as/logs for in 'ls $path | grep " . *.sh "| grep -v all_service_stop. sh| Xargs'; Do cd $path . / Done
2, 2 Linux machines for remote connection (Jenkins Server is also a Linux machine)
A, 2 machines execute ssh-keygen-t RSA, generate Id_rsa.pub file
B. Execute command on Jenkins Linux: scp/home/xxxx/.ssh/id_rsa.pub [email protected]:/home/xxxx/.ssh/authorized_keys Enter Password login
C, in the Jenkins Linux re-execution scp/home/xxxx/.ssh/id_rsa.pub [email Protected]:/home/xxxx/.ssh/authorized_keys will not have to enter the password login
3. Jenkins Build Execution shell command
SSH-T-P [email protected] "/app/jboss/jboss-as/logs/all_service_stop.sh"
You can execute the remote command.
Jenkins executes SSH remote Linux execution command