Code QuizAdvanced

Find nginx process PID

Spot the classic grep self-match bug when hunting a process ID from ps output.

Codebash
#!/bin/bash
# Find the nginx worker PID and stop it
PID=$(ps aux | grep nginx | awk '{print $2}')
kill "$PID"
journalctl -u nginx --since "5 minutes ago"

What is the bug in this script that finds and kills the nginx PID?