關於cronolog的用法檢視:https://www.freebsd.org/cgi/man.cgi?query=cronolog&apropos=0&sektion=0&manpath=FreeBSD+7.2-RELEASE+and+Ports&format=html
或者使用man cronolog:
[root@weblogic ~]# cronolog -h usage: cronolog [OPTIONS] logfile-spec -H NAME, --hardlink=NAME maintain a hard link from NAME to current log -S NAME, --symlink=NAME maintain a symbolic link from NAME to current log -P NAME, --prev-symlink=NAME maintain a symbolic link from NAME to previous log -l NAME, --link=NAME same as -S/--symlink -h, --help print this help, then exit -p PERIOD, --period=PERIOD set the rotation period explicitly -d DELAY, --delay=DELAY set the rotation period delay -o, --once-only create single output log from template (not rotated) -x FILE, --debug=FILE write debug messages to FILE ( or to standard error if FILE is "-") -a, --american American date formats -e, --european European date formats (default) -s, --start-time=TIME starting time -z TZ, --time-zone=TZ use TZ for timezone -V, --version print version number, then exit
1、安裝cronolog這個工具,這裡使用yum進行安裝:
[root@weblogic scripts]# yum whatprovides */cronolog Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base | 3.7 kB 00:00 epel | 4.7 kB 00:00 epel/primary_db | 6.0 MB 00:01 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 epel/filelists_db | 7.8 MB 00:05 extras/filelists_db | 26 kB 00:00 cronolog-1.6.2-10.el6.x86_64 : Web log rotation program for Apache Repo : epel Matched from: Filename : /usr/sbin/cronolog
[root@weblogic scripts]# yum -y install cronolog
安裝完成後,檢視執行程式位置:
[root@weblogic scripts]# which cronolog /usr/sbin/cronolog
2、使用cronolog給tomcat進行日誌切割,修改catalina.sh指令碼檔案:
修改之前為:
org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_OUT" 2>&1 &
修改完成後,啟動tomcat服務,檢視日誌檔案:
時間查不同,那是因為之前並沒有同步時間導致,於是切割tomcat日誌成功