Use the command
sudo netstat -plten |grep java
used grep java
as tomcat
uses java
as their processes.
It will show the list of processes with port number and process id
tcp6 0 0 :::8080 :::* LISTEN
1000 30070621 16085/java
the number before /java
is a process id. Now use kill
command to kill the process
kill -9 16085
-9
implies the process will be killed forcefully.
You can use the lsof command. Let port number like here is 8090
lsof -i:8090
This command returns a list of open processes on this port.
Something like…
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ssh 75782 eoin 5u IPv6 0x01c1c234 0t0 TCP localhost:8090 (LISTEN)
To free the port, kill the process using it(the process id is 75782)…
kill -9 75782
This one worked for me. here is the link from the original post: link
top
You may want to start by looking into top
or htop
result to see the processes overview.
htop
Similar to the top but with more information. As you can, it got the command column, which is handy to identify the process path. And, also it is colorful.
glances
As the name says, you get system utilization view on a single screen. Running processes are sorted by their CPU utilization.
atop
A similar to the above listed but with a brilliant feature to record the output in a file so you can view them later. Imagine, there is a pattern of having an issue at a specific time window. You can schedule to write the output in a file through crontab or other and later you can playback.
To record the output in a file:
atop -w filename
and, to playback:
atop -r filename
It supports multiple arguments like interval, samples, etc. and I would strongly recommend taking a look at the man page.
If you are just interested in real-time troubleshooting, then just execute atop
and you should see like below.
ps
Let’s check ps
command now.
You can use ps command with PID to print their CPU and memory utilization.
ps -p $PID -o %cpu,%mem
The output should look like this.
root@sr-master-us:~# ps -p 1048 -o %cpu,%mem
%CPU %MEM
0.2 3.0
root@sr-master-us:~#
nmon
Interactive command-line monitoring tool for CPU, memory, disks, network, NFS, and virtual memory utilization. To view the top process (by utilization), you can execute nmon
and press t
button.
Monit
Monit is a web-based and command-line open source solution to monitor server resources, daemons, files, directory, file systems, etc.
Monit also got a cool widget.
Monitorix
A lightweight open-source utility to monitor Linux server. Monitorix got in-built HTTP so you can check the utilization and other stuff on the web. Some of the other usage reports include:
- Kernal/temperature
- Filesystem and I/O
- Network traffic
- Apache/Mail/FTP/Nginx/MySQL/Varnish/Memcached/
Monitorix also offers alert configuration so you can get notified when things are not right. It will be a good choice when you are managing cloud-based servers and looking for a proactive monitoring solution.
Netdata
Netdata is a real-time performance monitoring for system resources, applications, web servers, databases, DNS, mail, hardware sensors, and a lot more. It is open-source and getting started is easy. All the data is collected, stored, and streamed for you to visualize interactively. Data is collected every second, so you never miss anything.
Loved by many industry leaders.
So what you are waiting for, try and take control of your Linux servers.