"Generating Background"
As the company's NTP Center server access is growing, access logs are increasing, the original log is not cut, a single log is too large (the largest 3.7G), if the clean up disk space will delete the entire access log, which will lose a lot of important information, Therefore, it is necessary to cut logs so that if you have too many files in the future, you can delete the history files.
Script
#!/bin/bashyesterday=$ (date-d yesterday +%y%m%d) gzip= "gzip-c" log_file= "/etc/httpd/logs/access_ntp.log" LOG_BACKUP _file= "/etc/httpd/logs/access_ntp_backup/access_ntp_${yesterday}.log.gz" $GZIP ${log_file} > ${LOG_BACKUP_FILE} >${log_file}
Add a script to cron
echo "0 0 * * */bin/sh/scripts/rotate_access_log.sh &>/dev/null" >>/var/spool/cron/root
Daily 0:0 generate a compressed log file in the/etc/httpd/logs/access_ntp_backup directory, as in the form of access_ntp_20160514.log.gz
Apache Log Split Script