finished debugging services
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# Debugging Services
|
||||
|
||||
The below are a bunch of commands that can be used to debug services on a Linux system (e.g. Java App / .NET App and so on)
|
||||
|
||||
#### Finding the process
|
||||
|
||||
```bash
|
||||
# Generic
|
||||
ps aux | grep <process_name>
|
||||
|
||||
# Java
|
||||
ps aux | grep java
|
||||
```
|
||||
|
||||
#### Find the service if a systemd service is running
|
||||
|
||||
```bash
|
||||
# Generic
|
||||
sudo systemctl status <service_name>
|
||||
|
||||
# Specific service
|
||||
sudo systemctl status myapp
|
||||
|
||||
# Find service
|
||||
sudo systemctl list-units --type=service | grep <service_name>
|
||||
```
|
||||
|
||||
#### View logs for a systemd service
|
||||
|
||||
```bash
|
||||
# Generic
|
||||
sudo journalctl -u <service_name> -n 100 --no-pager
|
||||
|
||||
# Specific service
|
||||
sudo journalctl -u myapp -n 100 --no-pager
|
||||
```
|
||||
|
||||
#### Check port for a service
|
||||
|
||||
```bash
|
||||
# Generic
|
||||
sudo ss -tulpn | grep <port_number>
|
||||
|
||||
# Specific port
|
||||
sudo ss -tulpn | grep 8080
|
||||
```
|
||||
|
||||
#### Search for OOM (Out of Memory) errors in logs
|
||||
|
||||
```bash
|
||||
# Generic
|
||||
sudo journalctl -k | grep -i "out of memory|kill|oom" | tail -n 100
|
||||
sudo dmesg | grep -i "out of memory|kill|oom" | tail -n 100
|
||||
```
|
||||
|
||||
#### System resource usage
|
||||
|
||||
```bash
|
||||
# Display memory usage
|
||||
free -h
|
||||
|
||||
# Disc usage
|
||||
df -h
|
||||
|
||||
# Usage on a specific directory
|
||||
du -sh /path/to/directory | sort -rh
|
||||
|
||||
# CPU
|
||||
top
|
||||
htop
|
||||
```
|
||||
Reference in New Issue
Block a user