title: CRON Alarm Clock Linux Mint Stops Suddenly
body: <p>I'm new to linux and I'm learning to script an alarm clock using bash and cron. The script works fine from bash and by double clicking on it, but not from cron; as soon as cron calls the script, the alarm sounds once (one loop, it seems) and then stops without even showing the dialog box (zenity). I'm using Linux Mint 13 Maya XFCE.</p>
  
  <p>Here is my crontab setup</p>
  
  <pre><code>* * * * * /home/x/Documents/MyScripts/Cron/BeepAlarm "Wake Up"
  </code></pre>
  
  <p>And here is my script</p>
  
  <pre><code>!#/bin/bash
  
  # Initialize Variables
  Text=$1
  Title="Alarm"
  OkLabel="Snooze"
  CancelLabel='Shut It Up!'
  Icon=/home/x/.icons/actions/48/appointment-new.png # Won't work
  SnoozeTimeout=120
  AlarmCycles=100
  shopt expand_aliases
  alias vol='amixer -q -c 0 sset Beep'
  vol 25% # Heart friendly
  rm -f LoopMode # Just in case =P
  
  # Dialog Box Function
  _MsgBox () {
      if zenity --question --title="$Title" \
      --window-icon=$Icon --ok-label="$OkLabel" \
      --cancel-label="$CancelLabel" --text="$Text"
      then
          echo 1 &gt; LoopMode
      else
          echo 2 &gt; LoopMode
          #kill -TERM `jobs -p` # Won't work
      fi
  }
  
  # Alarm Loop
  while [ $AlarmCycles -gt 0 ]; do
      case `cat LoopMode` in
          "") # Question Box
              echo 0 &gt; LoopMode
              _MsgBox &amp;
              ;;
  
          1)  # Snooze
              vol 25%
              rm -f LoopMode
              sleep $SnoozeTimeout
              ;;
  
          2)  # Stop Alarm
              break # But don't sleep again
              ;;
  
          *)  # Get on my nerves
              beep -r 4 -l 20 -f 2000; sleep 0.5
              beep -r 4 -l 20 -f 4000; sleep 0.5
              AlarmCycles=$((AlarmCycles-1))
              vol 5%+
  
      esac
  done
  
  # Housekeeping~
  kill $(($!+2)) # I don't know a better way to kill zenity Dialog
  vol 25%   #  =)
  rm -f LoopMode
  </code></pre>