Operating System - HP-UX
1846420 Members
2542 Online
110256 Solutions
New Discussion

Re: Scripting help required

 
SOLVED
Go to solution
ShivKumar_1
Frequent Advisor

Scripting help required

Hi experts,
I need help , in writing a script, that will identify the files created by a particular date under a directory.
******************************************
Eg:
/oracle/PRD/saparch

for Eg: for date 3/11/04 and then rcp them over to another server. Again tomorrow I need the files that were generated only for that date ie 3/12/04 and then rcp them alone.
What I am asking may be pretty basic, but the thing is I dont have much time to write the script as I need it by tomorrow. Any ideas or suggestions? I would really appreciate.

Thnks
SK
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: Scripting help required

I'd start out with a find command

eval find ${TmpDirList} -type f -mtime +${OLDEST} -print | \
sed -f ${ExceptSed} > ${RemoveList} 2>/dev/null

Important variables:

TmpDirList where to write temp file
OLDEST number of days, in this case probably zero.

You might want to use the caljd.sh script from http://www.hpux.ws/merijn to translate dates into information your script can use.

The script is well documented and can help with all kinds of date calculations.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
john korterman
Honored Contributor

Re: Scripting help required

Hi,
you can retrieve information about last modification or access time of a file, or when the inode for a file was changed, but unix does not store any information about file creation time.


regards,
John K.
it would be nice if you always got a second chance
Geoff Wild
Honored Contributor
Solution

Re: Scripting help required

How about this:

#!/bin/sh
TODAY=`date |awk '{print $2, $3}'`
for i in `ll |grep "$TODAY"|awk '{print $9}'`
do
rcp $i otherserver:/somedir
done

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
ShivKumar_1
Frequent Advisor

Re: Scripting help required

Hi
Thnks a lot for the scripts, 100% points to all of you.

Thnks
SK
Volker Borowski
Honored Contributor

Re: Scripting help required

Hmmm,

as this is SAP environment, why not use what is available ?

Do your standard "brarchive -s" on 00:00 each day to tape. This saves a copy of your archive files to the tape.
Anytime later, do a
brarchive -cd -d disk_copy

This saves all already saved archives to a configured destination, and deletes them afterwards. br-tools can even use scp with Rel. 6.20 and current patchlevel.

No need for script at all, and fully supported SAP Software at work :-)

Volker
ShivKumar_1
Frequent Advisor

Re: Scripting help required

Hi,
We have issues with our tape library. So we are unable to backup to tape.