Normally, log files are just text files that are appended with more lines of text whenever a specific event occurs. Rotation of log files means that the text files are periodically maintained and archived so that they don't get too big.
For Apache web server, there are a couple of log files (located in the /log/ folder just above the public directory) --
access.log
error.log
When these files are rotated, they will be archived under new files that look like this:
access.log.1
access.log.2
error.log.1
error.log.2
The log rotation is usually part of 3 maintenance setups located in the following directories;
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
These will be run from a cronjob with commands that look like this:
17 * * * * cd / && run-parts --report /etc/cron.hourly
25 6 * * * ( cd / && run-parts --report /etc/cron.daily ) | mail -s "cron daily" me@myemail.comnet
47 6 * * 7 ( cd / && run-parts --report /etc/cron.weekly ) | mail -s "cron weekly" duy@me@myemail.comnet
52 6 1 * * ( cd / && run-parts --report /etc/cron.monthly ) | mail -s "cron monthly" me@myemail.comnet
Another cronjob can be added to directly run logs separately from the daily crons (but the logrotate command might need to be specified with its path:
20 17 23 * * /usr/sbin/logrotate /etc/logrotate.conf
A status file shows the date when each log was last updated:
/var/lib/logrotate/status
There are configuration files located inside the directory:
/etc/logrotate.d
One of these is the /apache file. It will contain commands that may look like this:
/path/to/my/log/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
# CHANGE THIS SETTING IF PERMISSIONS ARE NOT CORRECT
# su myusername mygroupname
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
Keep up the wonderful piece of work, I read few posts on this internet site and I think that your blog is really interesting and holds bands of fantastic information. https://royalcbd.com/product/cbd-gummies-10mg/
ReplyDelete