I'm using bash shell on Ubuntu Linux 14.04. I have this script ...
SIDEKIQ_PID="$APP_ROOT/tmp/sidekiq.pid" SIDEKIQ_STOP_CMD="cd $APP_ROOT && bundle exec sidekiqctl stop $SIDEKIQ_PID 0" ... su - $USER -c "$SIDEKIQ_STOP_CMD" echo "Stopped sidekiq"
What I'm noticing is that if the PID no longer exists that is defined in my file "$SIDEKIQ_PID", the line
su - $USER -c "$SIDEKIQ_STOP_CMD"
dies with a "Process doesn't exist" error and the script doesn't continue (I can't see the following echo statement). How can I make my script continue even if the process no longer exists?