Find the answer to your Linux question:
Results 1 to 3 of 3
Our server created backup files every hour. I would like to automate burning the file created at 6:00 am automatically to a CD. the burning automation i have no problems ...
  1. #1
    Just Joined! pendal's Avatar
    Join Date
    Jan 2008
    Posts
    15

    Get a file created between certain times.

    Our server created backup files every hour.

    I would like to automate burning the file created at 6:00 am automatically to a CD.

    the burning automation i have no problems with.

    How do i select the file that is created say between 5:50am and 6:10am of the current date?

    here is a list of some of the files.
    Code:
    -rw-r--r--  1 root root 157814403 Sep  5 22:02 foxpro-1220666401-arc.tgz
    -rw-r--r--  1 root root 157814403 Sep  8 06:02 foxpro-1220868001-arc.tgz
    -rw-r--r--  1 root root 157814403 Sep  8 07:04 foxpro-1220871601-arc.tgz
    -rw-r--r--  1 root root 157814320 Sep  8 08:05 foxpro-1220875202-arc.tgz
    -rw-r--r--  1 root root 157823360 Sep  8 09:06 foxpro-1220878802-arc.tgz
    -rw-r--r--  1 root root 157825136 Sep  8 10:02 foxpro-1220882401-arc.tgz
    -rw-r--r--  1 root root 157824855 Sep  8 11:02 foxpro-1220886001-arc.tgz
    -rw-r--r--  1 root root 157816381 Sep  8 12:05 foxpro-1220889602-arc.tgz
    -rw-r--r--  1 root root 125812736 Sep  8 13:03 foxpro-1220893201-arc.tgz
    The file i would want in this case would be the second one down.

    My brain thinks the pattern would look similar to this.

    Code:
    dir="path/to/files"
    
    if[ creation BETWEEN "Today at 5:50" AND "Today at 6:10" ]
    add file to iso for backup
    fi
    
    run cd backup here
    I know that is nowhere near correct, but it is the best way I can express what i would like to accomplish.

    any help would be great.

    Thanks,
    -C

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    I had a similar situation similar to yours and here's how I did it:

    ST=`date "+%Y%m%d0550.00"`
    ET=`date "+%Y%m%d0610.00"`
    touch -t $ST /tmp/s
    touch -t $ET /tmp/e
    find $dir -type f -newer /tmp/s ! -newer /tmp/e -type f -exec cp {} $dest \;
    ##make iso file with files in $dest##
    #clean up
    rm -rf /tmp/s /tmp/e

    Hope that helps.

  3. #3
    Just Joined! pendal's Avatar
    Join Date
    Jan 2008
    Posts
    15
    That worked exactly perfect!!!!
    Thanks.

    For others who come across it, this was my final script that includes all iso and burning automation.

    Code:
    #SET TIMES
    ST=`date "+%Y%m%d0550.00"`
    ET=`date "+%Y%m%d0610.00"`
    
    #SET DIRS
    dir="/mnt/backup/foxpro"
    dest="/mnt/bktemps/"
    isoloc="/mnt/bkisos/"
    
    #SET ISO NAME
    isoname="fpbk.iso"
    
    #Find the file we want and copy to new location
    touch -t $ST /tmp/s
    touch -t $ET /tmp/e
    find $dir -type f -newer /tmp/s ! -newer /tmp/e -type f -exec cp {} $dest \;
    
    #make iso of dest dir
    mkisofs -o $isoloc$isoname $dest
    
    #burn iso to cd in drive
    wodim speed=16 dev=/dev/cdrom -v $isoloc$isoname
    
    #do cleanup
    rm -f /tmp/s /tmp/e $isoloc* $dest*
    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...