I am using Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-85-generic x86_64) where I created a simple Upstart job:

# content of /etc/init/listener.conf

start on runlevel [2345]
stop on runlevel [!2345]

exec /home/mk/log_listener

The script itself looks like this:


tail -F /var/log/vsftpd.log | while read line; do
    if echo "$line" | grep -q 'OK UPLOAD:'; then
         curl http://some.url/

But for some reason the job starts two processes:

$ ps jax | grep lis
   1  1234  1234  1234 ?           -1 Ss       0   0:00 /bin/sh /home/mk/log_listener
1234  1236  1234  1234 ?           -1 S        0   0:00 /bin/sh /home/mk/log_listener

I suppose this is not a "normal" behavior? How can I find out who and why is starting the second process and how to properly call the script in my Upstart job?

  • add a 'j' flag to ps (ps jax | grep listener) to confirm or deny the idea that the processes are related (parent/child).
    – Jeff Schaller
    Apr 14, 2016 at 16:24
  • I updated my post with the output of ps jax command.
    – errata
    Apr 14, 2016 at 16:31

1 Answer 1


We see that those two processes are related (the parent of PID 1236 is 1234) and that PID 1234 is the session leader (lower-case 's' in the STAT field).

See https://unix.stackexchange.com/a/18178/117549 where we see that pipelines in shell scripts create a new process group.

Thus, I believe that Upstart is executing your script correctly, and you are seeing two processes because of the tail ... | while read pipeline.

If I can suggest a small improvement to your script, you don't need to echo every line against grep inside your loop; instead:

tail -F /var/log/vsftpd.log | grep --line-buffered 'OK UPLOAD:' | while read unused
  curl http://some.url/
  • Thanks for your answer! I didn't quite understand the conclusion, so, this IS normal behavior (because both processes shown are part of the same PID)? Thanks for the script suggestion, I might update it also :)
    – errata
    Apr 15, 2016 at 9:47
  • Normal behavior; you can see it happen separately from upstart as well.
    – Jeff Schaller
    Apr 15, 2016 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .