GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script to clear archive log
Operating System - HP-UX
1849261
Members
5699
Online
104042
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 01:48 PM
11-24-2005 01:48 PM
Hi,
Currently Im running the backup of archive log using tar.
After that manually remove the archive log files.
Does anyone have a script to automatic tar the archive log, after that capture the files that been backup and remove it?
Currently Im running the backup of archive log using tar.
After that manually remove the archive log files.
Does anyone have a script to automatic tar the archive log, after that capture the files that been backup and remove it?
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 08:22 PM
11-24-2005 08:22 PM
Solution
Hi
Try the below script.. Modify the file names and locations accroding to your env.
cd /archdir/
ls -lrt |awk '{print $9}'>>/tmp/archivelogout.`date`
tar -cvf /tmp/archvlog.`date`.tar *
for i in `cat /tmp/archivelogout.`date`
do
tar -tvf /tmp/archvlog.`date`.tar|awk '{print $8}'|grep $i
logs=`echo $?`
if [ $logs -eq 0 ]
then
rm /archdir/$i
else
echo "$i not backed up">>/tmp/notbackedfile.`date`
fi
done
Pls do not try this script directly as this involvs a "rm" command. !!!! :)
Regards
CS
Try the below script.. Modify the file names and locations accroding to your env.
cd /archdir/
ls -lrt |awk '{print $9}'>>/tmp/archivelogout.`date`
tar -cvf /tmp/archvlog.`date`.tar *
for i in `cat /tmp/archivelogout.`date`
do
tar -tvf /tmp/archvlog.`date`.tar|awk '{print $8}'|grep $i
logs=`echo $?`
if [ $logs -eq 0 ]
then
rm /archdir/$i
else
echo "$i not backed up">>/tmp/notbackedfile.`date`
fi
done
Pls do not try this script directly as this involvs a "rm" command. !!!! :)
Regards
CS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 08:23 PM
11-24-2005 08:23 PM
Re: Script to clear archive log
Hi
Try the below script.. Modify the file names and locations accroding to your env.
cd /archdir/
ls -lrt |awk '{print $9}'>>/tmp/archivelogout.`date`
tar -cvf /tmp/archvlog.`date`.tar *
for i in `cat /tmp/archivelogout.`date`
do
tar -tvf /tmp/archvlog.`date`.tar|awk '{print $8}'|grep $i
logs=`echo $?`
if [ $logs -eq 0 ]
then
rm /archdir/$i
else
echo "$i not backed up">>/tmp/notbackedfile.`date`
fi
done
Pls do not try to run this without testing as it contains a "rm" command. !!!! :)
Regards
CS
Try the below script.. Modify the file names and locations accroding to your env.
cd /archdir/
ls -lrt |awk '{print $9}'>>/tmp/archivelogout.`date`
tar -cvf /tmp/archvlog.`date`.tar *
for i in `cat /tmp/archivelogout.`date`
do
tar -tvf /tmp/archvlog.`date`.tar|awk '{print $8}'|grep $i
logs=`echo $?`
if [ $logs -eq 0 ]
then
rm /archdir/$i
else
echo "$i not backed up">>/tmp/notbackedfile.`date`
fi
done
Pls do not try to run this without testing as it contains a "rm" command. !!!! :)
Regards
CS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2005 08:32 PM
11-24-2005 08:32 PM
Re: Script to clear archive log
Try as,
#!/bin/ksh
# User input -- Here
ARCHIVEDIR=/tmp/arcive
cd ${ARCHIVEDIR}
tar -cvf /archive_$(date +%d%m%y).tar *
if [[ ${?} -eq 0 ]]
then
echo "Archive of ${ARCHIVEDIR} is successful - $(date)"
rm -f *
else
echo "Archive of ${ARCHIVEDIR} is failure - $(date)"
# echo "Archive ttempt again" | mailx -s "Failure" mail ID
fi
# END
exit 0
Archive file will be in the format as, /archive_DDMMYY.tar file.
hth.
#!/bin/ksh
# User input -- Here
ARCHIVEDIR=/tmp/arcive
cd ${ARCHIVEDIR}
tar -cvf /archive_$(date +%d%m%y).tar *
if [[ ${?} -eq 0 ]]
then
echo "Archive of ${ARCHIVEDIR} is successful - $(date)"
rm -f *
else
echo "Archive of ${ARCHIVEDIR} is failure - $(date)"
# echo "Archive ttempt again" | mailx -s "Failure" mail ID
fi
# END
exit 0
Archive file will be in the format as, /archive_DDMMYY.tar file.
hth.
Easy to suggest when don't know about the problem!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP