sdruss
asked on
Need Perl Script to Archive Older Files
Our team typically uses Perl in our Solaris Oracle database environment. We need a Perl script, that will receive parameter, such as, “-keep 30, -keep 60, -keep 90”.
Script called (example): CleanUpOraDbFiles -keep 60
Also, PERL script will move gzip up files older than 60 days, and move to a larger file share of the filesystems. Need good example what this script would look like. Looking to archive-off ( listener.log, audit logs, alert logs, etc.. )
Script called (example): CleanUpOraDbFiles -keep 60
Also, PERL script will move gzip up files older than 60 days, and move to a larger file share of the filesystems. Need good example what this script would look like. Looking to archive-off ( listener.log, audit logs, alert logs, etc.. )
Be aware that the listener log is special. It is always open as long as the listener is running. You cannot just move the log out from underneath the listener.
It has been quite a while since I did it, but I believe that if you do this;
lsnrctl set log_status off
move/rename listener log
lsnrctl set log_status on
That should create a new log.
As far as I recall, that is the only log that behaves that way.
It has been quite a while since I did it, but I believe that if you do this;
lsnrctl set log_status off
move/rename listener log
lsnrctl set log_status on
That should create a new log.
As far as I recall, that is the only log that behaves that way.
Since you mention you have gzip files, you already have a script to zip them, correct?
Why write and maintain your own scripts when Solaris comes with a tool to maintain logs for you?
Check out logadm:
https://docs.oracle.com/cd/E23823_01/html/816-5166/logadm-1m.html
I'm running on RHEL and have a similar tool available called logrotate. It does everything I need it to do:
Copies off and zips logs and removes logs and trace files after the time I set.
Why write and maintain your own scripts when Solaris comes with a tool to maintain logs for you?
Check out logadm:
https://docs.oracle.com/cd/E23823_01/html/816-5166/logadm-1m.html
I'm running on RHEL and have a similar tool available called logrotate. It does everything I need it to do:
Copies off and zips logs and removes logs and trace files after the time I set.
ASKER
Wow, "logadm" sounds very interesting. I will take a look. Thanks!
ASKER
Dave, looks like a nice script. I will slightly modify and test tomorrow. Appreciate, thanks!!
ASKER
For testing purposes ..... What is a quick way to generate 50 dummy files, in 4 or 5 different directories to test?
Untested...
for dir in d1 d2 d3 d4
do
for i in {1..40}
do
touch $d/file$i
done
done
ASKER
Thanks. Still getting test environment set.
ASKER
Dave Cross: Not sure the following is working, and also have not seen this syntax before. Can you explain?
next if -C $_ < $cut_off;
next if -C $_ < $cut_off;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window