I am trying to check if a process is running. If it works, I want to get the return value "OK", and if I do not return the value "Out of Order". I can use "ps" without any other arguments (for example, ps -ef) if that is the correct term. The code I have is:
if ps | grep file; then echo 'OK'; else echo 'NO'; fi
The problem is that it does not search for the exact process and always returns “OK”, I do not want all the information to be displayed. I just want to know if the file exists.
linux bash grep process
chrissygormley
source share