Home » Infrastructure » Unix » Solaris5.9-->Command HELP
Solaris5.9-->Command HELP [message #208118] Fri, 08 December 2006 04:39 Go to next message
thiyagaraj
Messages: 41
Registered: August 2006
Member
Hi

We have enabled the sys audit on the live server.So it has created more than 3000 files in audit location.I have been asked by my seniorDBA to take a backup of these files to someother location and TAR and ZIP these files. If it is the archivelogs then we can easily do this,b'cos archivelogs will have an sequential ordered(i.e.arch0001,arch0002,..........arch000100...)format,so that I will create a TAR file like,
bash-2.05$tar -cvf arch0000006000_1TOarch0000006100_1.tar arch00000060*.log

But these audit files will not be the same file format as archives(i.e. 1290,1455,878,9900).In this case,I have an idea to order these audit files in monthwise,so that in future reference we can open a particular file which was created in the particular time.

For this ,
1. I have to list out the files which is craeted on the particular month(i.e.November2006).
What is the command to achieve this in Solaris5.9.
2. If I list out these files then ,what will be the command to create the TAR file.

Please help me.

Thanks/

-Raaj

Re: Solaris5.9-->Command HELP [message #208228 is a reply to message #208118] Fri, 08 December 2006 13:12 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Answer to question 2 first, since it's simpler :

You can TAR a list of files that are in a text file with the command :

tar -cvf backup_file.tar -L file_list.txt



As for question one, I know of no UNIX command that can find files changed in a specific month. "find" can find files that have changed in the last X days, though.

I have a PERL script "find_month.pl' that searches for files in a directory changed in a specific month :

#!/bin/perl

# Parameter 1 : Directory to search
$DIRECTORY = shift;
# Parameter 2 : Month ( 1 - 12 )
$MONTH     = shift;

opendir(DIR, $DIRECTORY);
  @FILELIST = readdir(DIR);
closedir(DIR);

foreach my $FILE (@FILELIST) {
	# Get File Information 
	($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("${DIRECTORY}/${FILE}");
	
	# Get Month from Modification Time ( returns 0 - 11 ) 
	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mtime);
	
	# check if Month is equal, and print filename if yes
	if (($mon + 1) == $MONTH){
		print "${DIRECTORY}/${FILE}\n";
        }
}	


So it could work like this :

find_month.pl /directory/ 12 > /tmp/file_list.txt
tar -cvf backup_file.tar -L /tmp/file_list.txt


You might want to test if it is atime / mtime / ctime that works for you, since they behave a little different on different filesystem, I think.

Hope that helps
Re: Solaris5.9-->Command HELP [message #209036 is a reply to message #208228] Wed, 13 December 2006 00:48 Go to previous message
thiyagaraj
Messages: 41
Registered: August 2006
Member
Thanks Thomas.
It works fine.
Previous Topic: Comparing contents of a file with data in database
Next Topic: Oracle Installation On Solaris10
Goto Forum:
  


Current Time: Thu Mar 28 20:27:00 CDT 2024