Sample Header Ad - 728x90

How do I check for the existence of a process without a failed exit code being returned?

2 votes
1 answer
3244 views
I’m using Amazon Linux. I want to start a process provided one isn’t running already. This is a bash script I embed within a Jenkins Maven job. So I have pids=$(pidof /usr/bin/Xvfb) if [ ! -n "$pids" ]; then Xvfb :0 -screen 5 1024x768x8 & fi Unfortunately, if there is no process, the line “pids=$(pidof /usr/bin/Xvfb)” returns a failing exit code and none of the other lines following are executed. Is there a way I can write the above such that no failed exit codes will be returned?
Asked by Dave (2808 rep)
Apr 28, 2016, 01:47 AM
Last activity: May 24, 2020, 06:41 AM