sam2929
asked on
how can i hide the password and also archive files with dates
Need a change in below script:
1) Want to encrypt the mdmdbpwd password how can i do that
2) I have another folder /userin/dev/archive i want to archive 10 days worth of file there with time stamp too.
like
marketing_acct_em.ixf_2014 0421 and marketing_acct_em.log_2014 0421
marketing_acct_em.ixf_2014 0420 and marketing_acct_em.log_2014 0420
and so on for 10 days after 10 days it should be deleted
1) Want to encrypt the mdmdbpwd password how can i do that
2) I have another folder /userin/dev/archive i want to archive 10 days worth of file there with time stamp too.
like
marketing_acct_em.ixf_2014
marketing_acct_em.ixf_2014
and so on for 10 days after 10 days it should be deleted
#!/bin/sh
#---- Set Environment
mdmdb="EMMDB"
mdmdbuser="MKT_DBO"
mdmdbpwd="time44up"
#-----PATH=$PATH:/db2_src/db2ruin/sqllib/bin
#------export PATH
. /db2_src/db2ruin/sqllib/db2profile
#---- Connect to the Database
db2 connect to $mdmdb user $mdmdbuser using $mdmdbpwd
#
# Whatever you want to do goes here...
#
db2 "EXPORT TO
/userin/MAT_Integration_dev/marketing_acct_em.ixf OF IXF
MESSAGES
/userin/MAT_Integration_dev/marketing_acct_em.log
select 'x' as id from SYSIBM.SYSDUMMY1"
#---- Terminate DB2
db2 terminate
ASKER
But this solution would be the same as placing your credentials in a separate file, so that you can share your script with others
Please tell me how can i do that
And also archive topic was not touched
Please tell me how can i do that
And also archive topic was not touched
For archiving, something like
find /userin/dev/archive -mtime +10 -exec rm '{}' \;
will remove all files older than 10 days in that directory and any subdirectories.
ASKER
what i need is archive then remove
For archive, to move a specific file to the archive directory, add this to the end of your script:
cp /userin/MAT_Integration_de v/marketin g_acct_em. log /userin/dev/archive/market ing_acct_e m_$(date '+%Y%m%d_%H%M%S').log
That will copy the named file, add a timestamp (as YYYYMMDD_HHMMSS) to the name, and put it into the archive directory.
The archive removal line I gave earlier doesn't actually look at the time and date in the file name - it relies ion the "last modified" timestamp built into the file information.
cp /userin/MAT_Integration_de
That will copy the named file, add a timestamp (as YYYYMMDD_HHMMSS) to the name, and put it into the archive directory.
The archive removal line I gave earlier doesn't actually look at the time and date in the file name - it relies ion the "last modified" timestamp built into the file information.
ASKER
getting below error when i put delete ate end of script
#---- Delete files older then 10 days from archive folder
find /userin/dev/archive/ -type f -mtime +10 -exec rm {}/
#---- Delete files older then 10 days from archive folder
find /userin/dev/archive/ -type f -mtime +10 -exec rm {}/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not familiar with the command line tools of DB2, so an alternative may be using certifications instead. But this solution would be the same as placing your credentials in a separate file, so that you can share your script with others, just place the credentials file in your home.