[wellylug] bash scripting help

jumbophut jumbophut at gmail.com
Wed Aug 4 13:26:58 NZST 2004


On Wed, 04 Aug 2004 12:18:07 +1200, Mark Signal wrote:
> if you are still with me... what I need to do is ensure that the rm -rf
> portion of the rsync script only runs on the first time that the scrip is
> run each day.
> 
> Maybe I could create a unique token file at the end of the first days rsync
> and check for it each time rsync is run..
> 
<snip>
> I am unsure if this is the best way to do this and how exactly to script the
> if-compare-then part of it.
> 
I am also unsure of whether this is the best way, but I have done
something similar with a backup script before:

Excerpt from:
<http://wellylug.org.nz/index.php?page=articles/article-display.php&&id=10>

working_dir="/tmp/backup/$(date +%Y%m%d)/" 
... 
if [ ! -d $working_dir ]; # check directory does not exist already
then mkdir -p $working_dir; 
else 
  echo 
  echo "Not proceeding because $working_dir exists! If there is nothing " 
  echo "important in that directory, delete the directory and rerun
this script."
  echo 
  exit; 
fi; 

Hope that helps.

-- 
Tony (echo 'spend!,pocket awide' | sed 'y/acdeikospntw!, /l at omcgtjuba.phi/')




More information about the wellylug mailing list