title: Getting an error code when deleting directory after mysqldump
body: <p>I am currently running a cronjob executing a bash-script for a mysqldump.</p>
  
  <pre><code>#!/bin/bash
  #
  
  # define variables
  TIMESTAMP=$(date +%Y-%m-%d_%H:%M)
  USER=mysqluser
  PASSWORD='myPassword'
  BACKUP_DIR=/backup
  
  # create directory with timestamp
  mkdir -p "$BACKUP_DIR/$TIMESTAMP"
  
  # dump database
  # compress file with GZip
  mysqldump --opt --user=$USER --password=$PASSWORD --host='host3.mydbserver.com' db1 | gzip -9 &gt; ${BACKUP_DIR}/$TIMESTAMP/backup-db1-$TIMESTAMP.sql.gz
  mysqldump --opt --user=$USER --password=$PASSWORD --host='host7.mydbserver.com' db2 | gzip -9 &gt; ${BACKUP_DIR}/$TIMESTAMP/backup-db2-$TIMESTAMP.sql.gz
  
  # find directories older than 120 minutes and delete recursively
  find $BACKUP_DIR/* -type d -mmin +120 -exec rm -r {} \;
  </code></pre>
  
  <p>The script seems to be working fine dumping the data into sql files in a timestamped directory. After executing the dump the script is to delete all folders older than 120 minutes, but I am getting an error code 1 from the cron service saying the directory of the script is nonexistent. The output for the find command is</p>
  
  <pre><code>find: '/backup/2020-05-22_13:30': No such file or directory
  </code></pre>
  
  <p>Any idea how I can avoid this error? </p>
  
  <p>EDIT 1: Once every couple of times I'm not getting the error code, without any changes in the code (it is currently running every 5 minutes for test purposes). I'm getting a feeling maybe this is a timing thing?</p>
  
  <p>EDIT 2: I'm a noob regarding all things Linux, scripting, bash etc. and I spent days getting as far as I did. So any downvoters please leave a comment to let me know what obvious thing I overlooked.</p>