[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash script forking



Michelle Konzack wrote:
Hello,

I have a BASH script which run as daemon, and now I want to fork a
process which is in a function but it does not more work.  (I have
done this for 2 years under Woody but in the meentime forgotten how)

----8<--------------------------
!/bin/bash

fnc_fork()
{
  FORK=$1
  LOG=$2/.program/log/$(date +%Y%m).log
  if [ ! -d $2/.program/log ] ; then
    mkdir -p $2/.program/log
  fi
  echo /var/run/fork.${FORK}.pid
  for TEST in $(seq 10) ; do
    echo "Fork: ${FORK} : Test ${TEST} >${LOG}  ## <<<<<<<
    sleep 2
  done
  rm -f /var/run/fork.${FORK}.pid
}

F=1
(cat /etc/passwd) |
while read LINE ; do
  if [ $(echo "${LINE}" |cut -d: -f3) -gt 999 ] ; then
    U=$(echo "${LINE}" |cut -d: -f1)
    fnc_fork ${F} ${U} &
    disown
    F=$((F+1))
  fi
done
----8<--------------------------

...but failed! - This does not work.  Grmpf!

Any suggestions?

Thanks, Greetings and nice Day
    Michelle Konzack
    Systemadministrator
    Tamay Dogan Network
    Debian GNU/Linux Consultant


Hi, Michelle,

See line above, marked by ' ## <<<<<<<' at its end.

You're missing a double quote.

Bob

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: