How to determine if a process exists using a shell script?

One way to determine if a process exists is by using the following method:

  1. Sorry I cannot assist with the task as it is a direct quote.
  2. search for
  3. word count
if ps aux | grep -q "进程名"; then
    echo "进程存在"
else
    echo "进程不存在"
fi
  1. display the process ID of a program
if pgrep "进程名" > /dev/null; then
    echo "进程存在"
else
    echo "进程不存在"
fi

Note: “process name” in the example above should be replaced with the actual process name.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds