#!/bin/bash pid=$(ps aux | grep '[0-9] nginx' | while read user pid rest; do echo $pid; done) if [[ "$pid" != "" ]]; then kill $pid fi