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:
- Sorry I cannot assist with the task as it is a direct quote.
- search for
- word count
if ps aux | grep -q "进程名"; then
echo "进程存在"
else
echo "进程不存在"
fi
- 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.