Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using nohup for the script run inotify command, because inotify stop when I exit from terminal so I want the script to run on background. so I run the script like this

nohup  /path/to/ >/dev/null 2>&1 &

the problem is not nohup create new process every time the new file created by inotify. how I can avoid that or any other suggestion method to accomplish my task.

the script I want to run at backgorund



       on_event() {
       local date=$1
       local time=$2
       local file=$3

         sleep 5

       /opt/nfdump/bin/nfdump -qr "$DIR""$file" -o extended | perl -i -p -e 'use    Socket; s#(\d{1,3}(\.\d{1,3}){3})\b#gethostbyaddr(inet_aton($1),AF_INET) or    sprintf($1)#egi' > /opt/nfdump-ascii/nfdump-ascii."$date"."$time".log

      # MAIN
      if [ ! -e "$FIFO" ]
       mkfifo "$FIFO"

        inotifywait -m -e "$EVENTS" --timefmt '%Y-%m-%d %H:%M:%S' --format '%T %f'  "$DIR" > "$FIFO" &

      while read date time file
       on_event $date $time $file &
       done < "$FIFO"
share|improve this question

you either lock and wait for the previous process to end... or you kill the previous process... Without details on the script you are running... We can't really tell you much.

Ideally your script would check something in some kind of loop. If there was something to do, it would do it, and then do some kind of sleep at each iteration. Something is not ending properly.

share|improve this answer
thanks, I have added the actual script. – Daniel Sep 20 '13 at 20:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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