diff --git a/template b/template index 57d3154..9dedf0d 100755 --- a/template +++ b/template @@ -35,10 +35,12 @@ case "$1" in cd "$dir" if [ -z "$user" ]; then sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & + echo $! > "$pid_file" else sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + sleep 1 # process not always started fast enough + echo $(pgrep -U "$user" -xf "$cmd") > "$pid_file" fi - echo $! > "$pid_file" if ! is_running; then echo "Unable to start, see $stdout_log and $stderr_log" exit 1