Monday, 15 June 2015

capture pid of tomcat to kill using bash script in Linux -



capture pid of tomcat to kill using bash script in Linux -

i trying write bash script finds pid of tomcat6, kills it, starts again, waits 1 minute, kills process 1 time again , starts again.

this have far struggling have script kill tomcat using previous pid:

ps aux | grep tomcat6 kill -9 $! service tomcat6 start sleep 1m ps aux | grep tomcat6 kill -9 $! service tomcat6 start

thanks

t_pid=$(ps aux | grep tomcat6 | awk 'nr==1{print $2}') kill -9 $t_pid service tomcat6 start sleep 1m

if grep gives multiple outputs, nr==x pid of desired line.

linux bash shell tomcat putty

No comments:

Post a Comment