title: Bash script stops execution in the middle of the script without any error
body: <p>I have this simple bash script that gets a copy from my dev server:</p>
  
  <pre><code>#!/bin/sh
  DATE=`date +%Y-%m-%d_%H%M.%S`
  BASEDIR="/var/www/db"
  RELEASEDIR="$DATE";
  RELEASEDIRFULL="$BASEDIR/releases/$RELEASEDIR"
  mkdir -p "$RELEASEDIRFULL"
  echo "Chdir to \"$RELEASEDIRFULL\""
  cd "$RELEASEDIRFULL"
  echo "Getting copy from dev"
  ssh dev.example.tld "cd /tmp; cd /sites/db; tar -zcvp --exclude data --exclude scripts -f - *" | tar zxvpf -
  ln -s /var/www/db/data data
  ln -s /var/www/db/scripts scripts
  cd $BASEDIR
  rm htdocs; ln -s releases/$RELEASEDIR htdocs
  </code></pre>
  
  <p>Recently it stopped working properly with no apparent reason. It gets to the ssh line, executes it fine (files appear on live server) but does not proceed with ln commands. If I comment the ssh line out, ln lines will get executed properly.</p>
  
  <p>UPDATE: I noticed that when I'm logged on as www-data and start the script, it completes as expected, without errors.</p>