Sponsored Content
Top Forums Shell Programming and Scripting Logrotate.d for every httpd instance for loop? Post 302968335 by xgringo on Tuesday 8th of March 2016 10:46:54 AM
Old 03-08-2016
Thanks for your patience in advance.

Code:
[root@/usr/local/scripts]# ls -ltr
-rwxrwxrwx 1 root root  253 Mar  8 09:41 examplelogconfig
drwxr-xr-x 2 root root 4096 Mar  8 09:51 stage
-rwxrwxrwx 1 root root  276 Mar  8 10:13 logrot.sh

[root@/apps/apache]# ls -ltr
drwxr-x--- 9 awdmw awdmw 4096 Jul 19  2013 httpd-fibcbeta
drwxr-x--- 9 awdmw awdmw 4096 Jul 19  2013 httpd-fibctrain
drwxr-x--- 9 awdmw awdmw 4096 Oct 17  2013 httpd-gundsdev
drwxr-x--- 9 awdmw awdmw 4096 Oct 31  2013 httpd-gundstrain
drwxr-x--- 9 awdmw awdmw 4096 Feb 21  2014 httpd-dliqat
drwxr-xr-x 9 awdmw awdmw 4096 Mar 11  2014 httpd-dlidev
drwxr-x--- 9 awdmw awdmw 4096 Apr  1  2014 httpd-dliuat
drwxr-x--- 9 awdmw awdmw 4096 Apr  2  2014 httpd-dlitrain

[root@uxtwsadcmrk01 logrotate.d]# ls –ltr

-rw-r--r--. 1 root root 329 Jul 10  2012 psacct
-rw-r--r--. 1 root root 540 Aug 30  2012 syslog
-rw-r--r--  1 root root  32 Nov  6  2012 up2date
-rwxr-x---  1 root root 259 Jul 19  2013 httpd-fibcbeta
-rwxr-x---  1 root root 261 Jul 19  2013 httpd-fibctrain
-rwxr-x---  1 root root 259 Oct 17  2013 httpd-gundsdev


The examplelogconfig in the usr/local/scripts dir and the httpd-fibcbeta in the logrotate.d are the same file, I was just trying to use teh exampleconfig, and look through the /apps/apache/ directory see which names are there, and then create a file for each one in the /etc/logrotate.d directory except change the host name. The caviat is I can't just put them in production so I have to put them in /usr/local/scripts/stage/ directory for later putting them in production. I have a ton of boxes to do this on, with normally a bunch of instances of jvms etc in /apps/apache/ and not much in /etc/logrotate.d ---- if this were just a few not a big deal but there are a ton of webs for me to do etc.
Code:
Cat httpd-fibctrain

/apps/apache/httpd-fibctrain/logs/*log {
    rotate 7
    compress
    missingok
    notifempty
    sharedscripts
    daily
    delaycompress
    nomail
    postrotate
        /sbin/service httpd-fibctrain reload > /dev/null 2>/dev/null || true
    endscript
}

Code:
[root@/usr/local/scripts]# cat examplelogconfig
/apps/apache/examplehost/logs/*log {
    rotate 7
    compress
    missingok
    notifempty
    sharedscripts
    daily
    delaycompress
    nomail
    postrotate
        /sbin/service examplehost reload > /dev/null 2>/dev/null || true
    endscript
}

So I was trying to say

if the directory exist in /apps/apache/*httpd* then create a file from the exampleconfig for each instance that (doesn't already exist) in /etc/logrotate.d/ directory and then change out the example host in the file with the hostname of the /apps/apache/*httpd* name and place a copy of that new example config named httpd- into /usr/local/scripts/stage/

Last edited by xgringo; 03-08-2016 at 11:55 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace first instance(not first instance in line)

Alright, I think I know what I am doing with sed(which probably means I don't). But I cant figure out how to replace just the first occurance of a string. I have tried sed, ed, and grep but can't seem to figure it out. If you have any suggestions I am open to anything! (3 Replies)
Discussion started by: IronHorse7
3 Replies

2. Shell Programming and Scripting

[PHP] endless loop mimics a cron. Make sure only one instance is running

Hi, PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime. I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file. However, I'd like to make sure... (2 Replies)
Discussion started by: jjshell
2 Replies

3. UNIX for Advanced & Expert Users

logrotate with /etc/logrotate.conf file

Hi there, I want to rotate the logfiles which are located in /var/log/jboss/tomcat* so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content. # cat /etc/logrotate.d/tomcat /var/log/jboss/tomcat_access_log*.log { daily nocreate ... (2 Replies)
Discussion started by: skmdu
2 Replies

4. Red Hat

logrotate httpd logfiles

Hi, I need to logrotate logs in directories in /var/log/httpd/. There are 4 directories in /var/log/httpd/... these directories are /var/log/httpd/access/ /var/log/httpd/debug/ /var/log/httpd/error/ /var/log/httpd/required/ Each of the access, required, error and debug directories have around... (1 Reply)
Discussion started by: renuka
1 Replies

5. Linux

LogRotate

Hi I am trying to rotate specific log by using logrotate function in unix I have made following entry in the /etc/logrotate.conf file /var/log/testlog/debug_log { daily rotate 7 create compress } But only issue is that my other logs like /var/log/messages,... (2 Replies)
Discussion started by: SiddhV
2 Replies

6. Red Hat

Logrotate on RHEL 5

Hi All, Can any one let me me know if i run /usr/sbin/logrotate /etc/logrotate.conf will it read the whole /var/log/messages or it just see the time stamp of message file & then rotate the logs. Just wants to know is logrotation based on messages file contents or messages file time stamp. ... (1 Reply)
Discussion started by: ajaincv
1 Replies

7. Shell Programming and Scripting

Logrotate - I am not able to rotate files using logrotate

I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest. I am using below command... (5 Replies)
Discussion started by: VSom007
5 Replies

8. AIX

Logrotate - /etc/logrotate.conf does't exist

Hi Admins. I have installed logrotate rpm on Aix 6.1. After the installation of rpm, I don't find /etc/logrotate.conf file and /etc/logrotate.d dir . The config file is located in /opt/freeware/etc/logrotate.conf. When I ran logrotate -v /opt/freeware/etc/logrotate.conf I get below... (2 Replies)
Discussion started by: snchaudhari2
2 Replies

9. UNIX for Dummies Questions & Answers

Logrotate configuration

Hi all, i would like to have a configuration on log rotate that will gzip my log files with date pattern %Y-%m-%d move these files to an olddir, but i want to avoid that the logrotate removes my files from old dir newer than 180 days i applyied this config #logrotate config to compress files... (3 Replies)
Discussion started by: charli1
3 Replies

10. Shell Programming and Scripting

Loop to run commands - after the previous instance completed

Hi All, I am trying to call a shell script in a loop. I want my first instance to complete, and then the 2nd instance of the command to start - and so on. eg. I am running this script 30 times. The wrapper script needs business date, from_time,to_time & server_name as inputs. script_name... (2 Replies)
Discussion started by: neil.k
2 Replies
CHECKBASHISMS(1)					      General Commands Manual						  CHECKBASHISMS(1)

NAME
checkbashisms - check for bashisms in /bin/sh scripts SYNOPSIS
checkbashisms script ... checkbashisms --help|--version DESCRIPTION
checkbashisms, based on one of the checks from the lintian system, performs basic checks on /bin/sh shell scripts for the possible presence of bashisms. It takes the names of the shell scripts on the command line, and outputs warnings if possible bashisms are detected. Note that the definition of a bashism in this context roughly equates to "a shell feature that is not required to be supported by POSIX"; this means that some issues flagged may be permitted under optional sections of POSIX, such as XSI or User Portability. In cases where POSIX and Debian Policy disagree, checkbashisms by default allows extensions permitted by Policy but may also provide options for stricter checking. OPTIONS
--help, -h Show a summary of options. --newline, -n Check for "echo -n" usage (non POSIX but required by Debian Policy 10.4.) --posix, -p Check for issues which are non POSIX but required to be supported by Debian Policy 10.4 (implies -n). --force, -f Force each script to be checked, even if it would normally not be (for instance, it has a bash or non POSIX shell shebang or appears to be a shell wrapper). --extra, -x Highlight lines which, whilst they do not contain bashisms, may be useful in determining whether a particular issue is a false posi- tive which may be ignored. For example, the use of "$BASH_ENV" may be preceded by checking whether "$BASH" is set. --version, -v Show version and copyright information. EXIT VALUES
The exit value will be 0 if no possible bashisms or other problems were detected. Otherwise it will be the sum of the following error val- ues: 1 A possible bashism was detected. 2 A file was skipped for some reason, for example, because it was unreadable or not found. The warning message will give details. SEE ALSO
lintian(1). AUTHOR
checkbashisms was originally written as a shell script by Yann Dirson <dirson@debian.org> and rewritten in Perl with many more features by Julian Gilbey <jdg@debian.org>. DEBIAN
Debian Utilities CHECKBASHISMS(1)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy