Skip to main content
3 of 7
added 159 characters in body
user2683246
  • 3.6k
  • 32
  • 31
if [ -e /proc/$PID ] 

or

if [ -n "$(ps -p $PID -o pid=)" ] 

In the latter form, -o pid= is an output format to display only the process ID column with no header. The quotes are necessary for non-empty string operator -n to give valid result.

user2683246
  • 3.6k
  • 32
  • 31