0

I wish to log /home/michael/client's stdout, but wish to remove lines containing various text. How is this accomplished? Below is what I attempted. Thanks

SCRIPT=/home/michael/client
RUNAS=michael
PIDFILE=/var/run/client.pid
LOGFILE=/var/log/client.log
PROG="Client Interface"

start() {
  if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
    echo "$PROG already running" >&2
    return 1
  fi
  echo "Starting $PROG…" >&2
  local CMD="$SCRIPT   >&3 2>&1 & echo \$!"
  #local CMD="$SCRIPT  | grep -v 'Non-block' | grep -v 'Connecting with ssl...' >&3 2>&1 & echo \$!"
  cd `dirname $SCRIPT`
  su -c "$CMD" $RUNAS  3>>"$LOGFILE" >"$PIDFILE"
  #su -c "$CMD" $RUNAS  | grep -v "Non-block" | grep -v "Connecting with ssl..." 3>> "$LOGFILE" >"$PIDFILE"
  #su -c "$CMD" $RUNAS  3>> grep -v "Non-block" | grep -v "Connecting with ssl..." | "$LOGFILE" >"$PIDFILE"
  echo "$PROG started" >&2
}
0

"divide et impera"

  1. are you able to write a plain bash script to do your task ?

  2. then try it with su

  3. then try it with nohup

  4. finally try to run as a init.d script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.