1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

get process id of openvpn client in bash script

Discussion in 'Main Forum' started by MountainX, Sep 12, 2018.

Tags: Add Tags
  1. MountainX

    MountainX Guest

    In a bash script I am starting openvpn as a client like this:

    command_line="/usr/bin/openvpn --config $conf_file --daemon"
    echo "openvpn_pid=$openvpn_pid"
    echo $openvpn_pid >> "$openvpn_pid_file"

    After a successful start of openvpn, my variable openvpn_pid is empty and my openvpn_pid_file is empty. However, pgrep openvpn will give me the PID. Why am I not getting that PID in my script? What should I change in order to get the correct PID in my variable and ultimately into the openvpn_pid_file?

    This is all on Arch Linux.

    Login To add answer/comment

Share This Page