I have an upstart configuration for a service which needs to check the existance of a process on it's startup. This sounds fairly easy but I'm already trying for 3 hours to get this thing solved and I'm lost. The problem seems to be that some grep statements lead to an exit of the script within upstart, leading to a failure in starting the service. But upstart doesn't log anything, it just exits the script and is gone.
Following are some example lines which trigger the problem: The first echo and the output of it's grep are logged, the second echo is logged, but not the output of it's grep. After the second echo upstart just exits the script and stops. The problem is adding the -v option or something other like using regexp classes like [[:digit:]]. It seems like I need to escape some characters but I simply don't know how. A simple -v or something like that doesn't work.
script
echo grep
ps ax | grep "postgres: wal writer process" | grep "grep"
echo grep2
ps ax | grep "postgres: wal writer process" | grep -v "grep"
end script
Does anyone has an idea on what I'm doing wrong and how to fix the problem?