gudii9
asked on
cleanup script
hi,
we have about 3 users say user1, user2, user3 on the weblogic server. The application logs and server logs getting filled up every 3 weeks or so causing server to choke. How to write a script to clean automatically those application log and server log folder contents automatically say every week on friday midngiht at 11 PM
please advise
we have about 3 users say user1, user2, user3 on the weblogic server. The application logs and server logs getting filled up every 3 weeks or so causing server to choke. How to write a script to clean automatically those application log and server log folder contents automatically say every week on friday midngiht at 11 PM
please advise
ASKER
$ /etc/logrotate.d
-bash: /etc/logrotate.d: is a directory
i got message as above.
i do not have tht looks like
any sample script or link or resource for this?
-bash: /etc/logrotate.d: is a directory
i got message as above.
i do not have tht looks like
any sample script or link or resource for this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops... Erik is correct... /etc/logrotate.d is a directory where all the config files live.
The logrotate program can be run manually + you'll refer to man logrotate for how to run logrotate manually.
Usually you'll use the -dv option to debug a new config file.
The logrotate program can be run manually + you'll refer to man logrotate for how to run logrotate manually.
Usually you'll use the -dv option to debug a new config file.
ASKER
any other alternate solution like simple sample script to this apart from logrotate? please advise
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To answer your question, "any other alternate solution like simple sample script to this apart from logrotate? please advise".
I'd go with Erik's comment.
Why?
You'd basically have to recode logrotate, which has been working... geez... for well over a decade.
Certainly possible, if you have lots of free time.
If you'd prefer to just have something working instantly, use logrotate, which every primary Linux Distro uses to rotate logs.
I'd go with Erik's comment.
Why?
You'd basically have to recode logrotate, which has been working... geez... for well over a decade.
Certainly possible, if you have lots of free time.
If you'd prefer to just have something working instantly, use logrotate, which every primary Linux Distro uses to rotate logs.
ASKER
any sample script examples?
Sample scripts? No. Why? Because it would require custom coding. Why? Because everyone who knows what they're doing would use logrotate, not kludge together their own script.
So I'll ask again: What exactly do you feel logrotate doesn't provide you that you're attempting to reinvent the wheel for?
So I'll ask again: What exactly do you feel logrotate doesn't provide you that you're attempting to reinvent the wheel for?
ASKER
You'll have to install logrotate if it isn't installed + refer to your Distro docs to determine where logrotate config files live.
Most mainstream Distros install logrotate by default, to guard /var/log/* files from eating all of disk space.
first of all i am not unix or linux guy but a java person
second my company has separate team to handle all these web logic servers on unix and linux servers.
all we do is create domain directory and use it to deploy applications and clean up logs once in a while.
I am not sure if they can install it for me.
any sample vidoes on how to do this and more about logrotate?
As previously noted, based on a previous commented you posted, I believe you already have logrotate installed. You could execute a command like "which logrotate" to confirm. On my system, the logrotate command is located at "/usr/sbin/logrotate" as is executable by all users.
The command's manpage, which can be read here, notes the command syntax, configuration file format, and provides some select examples. It allows you to use a custom config and state file location if you don't have root authority on the system.
Logrotate really is the best solution for this type of problem. Generally speaking, it's primary mode of action, is to rename the logfile, typically to a date based format), compresses it. As archived log files accumulate past time rules, it will trim the oldest ones. There is virtually a limitless combination of configuration options to tailor it's behavior to your exact needs; you can even have it fire a custom script somewhere in the process, using, e.g., the prerotate/postrotate directives.
[root@localhost ~]# ls -la /usr/sbin/logrotate
-rwxr-xr-x. 1 root root 70248 Aug 1 20:12 /usr/sbin/logrotate
[root@localhost ~]# ls -ld /usr/sbin
dr-xr-xr-x. 2 root root 20480 Jan 8 07:20 /usr/sbin
[root@localhost ~]# ls -ld /usr
drwxr-xr-x. 13 root root 4096 Dec 12 2016 /usr
[root@localhost ~]#
The command's manpage, which can be read here, notes the command syntax, configuration file format, and provides some select examples. It allows you to use a custom config and state file location if you don't have root authority on the system.
Logrotate really is the best solution for this type of problem. Generally speaking, it's primary mode of action, is to rename the logfile, typically to a date based format), compresses it. As archived log files accumulate past time rules, it will trim the oldest ones. There is virtually a limitless combination of configuration options to tailor it's behavior to your exact needs; you can even have it fire a custom script somewhere in the process, using, e.g., the prerotate/postrotate directives.
ASKER
"which logrotate" to confirm. On my system, the logrotate command is located at "/usr/sbin/logrotate" as is executable by all users.when i gave above command it showed same path as yours
/usr/sbin/logrotate
ASKER
now how to delete all the log files older than say 1 month
and also all the tmp file older than 1 week
etc.
Please advise
and also all the tmp file older than 1 week
etc.
Please advise
Just get into your /etc/logrotate.d directory + look through the files there.
Find one which is close to what you require + clone it + rename top lines to match your log files.