I have a shell script which is running in cronjob. This shell script has start with killing the process if it is already running and start the new process again.
To do so I wrote the below line at the beginning of my shell script.
First step is to find the PID (Process Id) and once that is found use the kill -9 command to terminate the running process without knowing the PID.
ps -ef | grep soffice | grep -v grep | awk '{ print $2 }'
Final command –
kill -9 $(ps -ef | grep soffice | grep -v grep | awk '{ print $2 }')
Jkoder.com Tutorials, Tips and interview questions for Java, J2EE, Android, Spring, Hibernate, Javascript and other languages for software developers