Consider the following dummy backup script:
#!/bin/bash
echo "rsync started"
sleep 1 # rsync time
echo "rsync completed"
echo "starting upload"
sleep 5 # upload time
echo "upload completed"
and the following minimal start script
#!/bin/bash
/path/to/backup.sh|awk '/^rsync completed/ {print "Restarting services"}'
echo "backup completed"
I would have expected the "Restarting services" output to appear after one second, but instead it appears at the end after 6 seconds, when running under Debian Wheezy.
Where is my mistake? Why isn't the awk action directly handled when the "rsync compeleted" string is written to stdout?