Print this page
Bump Apache dependency to Apache 2


 810 .in -2
 811 .sp
 812 
 813 .LP
 814 \fBExample 6 \fRRotating the apache Error and Access Logs
 815 .sp
 816 .LP
 817 The following example rotates the apache error and access logs monthly to
 818 filenames based on current year and month. It keeps the 24 most recent copies
 819 and tells apache to restart after renaming the logs.
 820 
 821 .sp
 822 .LP
 823 This command is run once, and since the \fB-w\fR option is specified, an entry
 824 is made in \fB/etc/logadm.conf\fR so the apache logs are rotated from now on.
 825 
 826 .sp
 827 .in +2
 828 .nf
 829  % logadm -w apache -p 1m -C 24\e
 830      -t '/var/apache/old-logs/$basename.%Y-%m'\e
 831      -a '/usr/apache/bin/apachectl graceful'\e
 832      '/var/apache/logs/*{access,error}_log'
 833 .fi
 834 .in -2
 835 .sp
 836 
 837 .sp
 838 .LP
 839 This example also illustrates that the entry name supplied with the \fB-w\fR
 840 option doesn't have to match the log file name. In this example, the entry name
 841 is \fBapache\fR and once the line has been run, the entry in
 842 \fB/etc/logadm.conf\fR can be forced to run by executing the following command:
 843 
 844 .sp
 845 .in +2
 846 .nf
 847 % logadm -p now apache
 848 .fi
 849 .in -2
 850 .sp
 851 
 852 .sp
 853 .LP
 854 Because the expression matching the apache log file names was enclosed in
 855 quotes, the expression is stored in \fB/etc/logadm.conf\fR, rather than the
 856 list of files that it expands to. This means that each time \fBlogadm\fR runs
 857 from \fBcron\fR it expands that expression and checks all the log files in the
 858 resulting list to see if they need rotating.
 859 
 860 .sp
 861 .LP
 862 The following command is an example without the quotes around the log name
 863 expression. The shell expands the last argument into a list of log files that
 864 exist at the time the command is entered, and writes an entry to
 865 \fB/etc/logadm.conf\fR that rotates the files.
 866 
 867 .sp
 868 .in +2
 869 .nf
 870 logadm -w apache /var/apache/logs/*_log
 871 .fi
 872 .in -2
 873 .sp
 874 
 875 .SH FILES
 876 .sp
 877 .ne 2
 878 .na
 879 \fB\fB/etc/logadm.conf\fR\fR
 880 .ad
 881 .sp .6
 882 .RS 4n
 883 configuration file for \fBlogadm\fR command
 884 .RE
 885 
 886 .SH ATTRIBUTES
 887 .sp
 888 .LP
 889 See \fBattributes\fR(5) for descriptions of the following attributes:
 890 .sp




 810 .in -2
 811 .sp
 812 
 813 .LP
 814 \fBExample 6 \fRRotating the apache Error and Access Logs
 815 .sp
 816 .LP
 817 The following example rotates the apache error and access logs monthly to
 818 filenames based on current year and month. It keeps the 24 most recent copies
 819 and tells apache to restart after renaming the logs.
 820 
 821 .sp
 822 .LP
 823 This command is run once, and since the \fB-w\fR option is specified, an entry
 824 is made in \fB/etc/logadm.conf\fR so the apache logs are rotated from now on.
 825 
 826 .sp
 827 .in +2
 828 .nf
 829  % logadm -w apache -p 1m -C 24\e
 830      -t '/var/apache2/2.2/old-logs/$basename.%Y-%m'\e
 831      -a '/usr/apache2/2.2/bin/apachectl graceful'\e
 832      '/var/apache2/2.2/logs/*{access,error}_log'
 833 .fi
 834 .in -2
 835 .sp
 836 
 837 .sp
 838 .LP
 839 This example also illustrates that the entry name supplied with the \fB-w\fR
 840 option doesn't have to match the log file name. In this example, the entry name
 841 is \fBapache\fR and once the line has been run, the entry in
 842 \fB/etc/logadm.conf\fR can be forced to run by executing the following command:
 843 
 844 .sp
 845 .in +2
 846 .nf
 847 % logadm -p now apache
 848 .fi
 849 .in -2
 850 .sp
 851 
 852 .sp
 853 .LP
 854 Because the expression matching the apache log file names was enclosed in
 855 quotes, the expression is stored in \fB/etc/logadm.conf\fR, rather than the
 856 list of files that it expands to. This means that each time \fBlogadm\fR runs
 857 from \fBcron\fR it expands that expression and checks all the log files in the
 858 resulting list to see if they need rotating.
 859 
 860 .sp
 861 .LP
 862 The following command is an example without the quotes around the log name
 863 expression. The shell expands the last argument into a list of log files that
 864 exist at the time the command is entered, and writes an entry to
 865 \fB/etc/logadm.conf\fR that rotates the files.
 866 
 867 .sp
 868 .in +2
 869 .nf
 870 logadm -w apache /var/apache2/2.2/logs/*_log
 871 .fi
 872 .in -2
 873 .sp
 874 
 875 .SH FILES
 876 .sp
 877 .ne 2
 878 .na
 879 \fB\fB/etc/logadm.conf\fR\fR
 880 .ad
 881 .sp .6
 882 .RS 4n
 883 configuration file for \fBlogadm\fR command
 884 .RE
 885 
 886 .SH ATTRIBUTES
 887 .sp
 888 .LP
 889 See \fBattributes\fR(5) for descriptions of the following attributes:
 890 .sp