两个脚本文件

1.ssh自动登陆脚本:

#!/usr/bin/expect -f

set ipaddr "192.168.0.144"
set loginuser "hongguangyan"
set loginpass "0u1y4hongguangyan"
set timeout 10

spawn ssh $loginuser@$ipaddr -p 22
expect "*assword:*"
send "$loginpass\r"
expect "]$"

interact

2.jenkins启动、关闭:

DESC="Jenkins CI Server"
NAME=jenkins
PIDFILE=/var/run/$NAME.pid
RUN_AS=jenkins
COMMAND=nohup /usr/bin/java -jar /Users/hgy/jenkins.war --httpPort=1234 > jenkins.log 2>&1
d_start() {
	 $COMMAND
}
d_stop() 
{
pid=`(ps -ef | grep jenkins.war | grep -v "grep") | awk '{print $2}'`
kill -9 $pid
}
case $1 in
	start)
	echo -n "Starting $DESC: $NAME"
	d_start
	echo "."
	;;
	stop)
	echo -n "Stopping $DESC: $NAME"
	d_stop
	echo "."
	;;
	restart)
	echo -n "Restarting $DESC: $NAME"
	d_stop
	sleep 1
	d_start
	echo "."
	;;
	*)
	echo "usage: $NAME {start|stop|restart}"
	exit 1
	;;
esac

exit 0

你可能感兴趣的:(脚本,command,kill,ssh)