I have an OpenVPN server which triggers a bash script when a connection is established. This script uses wget to post information to another server.

Today I noticed that when this other server is not reachable, wget fails, which makes the bash script return a failure, and the connection from the client aborts due to an "authentication problem". The problem was that the logging server could not get reached, but this should not be a reason for the connection to get aborted.

What can I do so that the entire script, which is triggered by a client-connect /home/user/openvpn/scripts/client-connected.sh entry in the ovpn config file, always succeeds?

1 Answer 1


The simplest way would be to tell it to explicitly exit with 0 (success):


rest of your script here

exit 0

This assumes that your script will always run through to the end, so that exit 0 is always the last thing that happens.

  • What could cause the script not to run through to the end, except for an earlier exit call? Does the exit 0 get reached regardless of wget failing? I've read something about set +x, how could I use this if it were useful?
    – Daniel F
    Oct 23, 2020 at 13:03
  • 1
    @DanielF if you chain commands together with &&, and the last one is the exit, then the exit won't run if the previous failed. Alternatively, if you have used set -e (exit on error), it also won't run. Since you didn't show us your script at all, I had to guess. Assuming you don't have anything like that then yes, the exit will run even if the wget fails. set -x shows you the exact commands run as parsed by the shell (see help set).
    – terdon
    Oct 23, 2020 at 13:07
  • Thanks, the script looks like yours, with rest of your script here being the wget call.
    – Daniel F
    Oct 23, 2020 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .