Yadu Krishnan
Yadu Krishnan

Reputation: 3522

Kill a java jar process before starting the jar file again

I have an executable jar file in a particular path, say /home/admin/apps . I am building the jar file through jenkins and copies the jar file to /home/admin/apps directory. After the copying, I also have another shell script(invoked from jenkins) which just runs nohup java -jar myjar.jar. But before running the jar file, i want to stop the earlier running process. How can I do that? I want to run all these through jenkins without manual effort.

Upvotes: 1

Views: 3548

Answers (1)

Arnab Nandy
Arnab Nandy

Reputation: 6692

You can use pkill -f 'java -jar'

Upvotes: 6

Related Questions