How to Automatically Kill a Process Using Script? [Duplicate]
How to Write a Script That Kills a Java Process? from Console It Looks Like Root@Ubuntu-S-1Vcpu-1Gb-Ams3-01: ~# Lsof -I Tcp:8080 Command Pid User Fd Type...
How to write a script that kills a java process?
From console it looks like
root@ubuntu-s-1vcpu-1gb-ams3-01:~# lsof -i tcp:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 9657 root 26u IPv6 4694148 0t0 TCP *:http-alt (LISTEN)
root@ubuntu-s-1vcpu-1gb-ams3-01:~# kill 9657
How should it be implemented in .sh file?
Just use the killall command. That should work.
Like this:
killall java
(Just in case you don't know how to create a executable .sh file (It's not quite clear): A .sh file should begin with a shebang, something like
#!/bin/sh
After that, you just write commands like you would in a terminal, separated into lines. Then you run
chmod +x <insert filename>
and are able to execute the .sh file just fine.
killall should be no exception