使用cronolog工具给tomcat进行日志切割

关于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日志成功

转载于:https://www.cnblogs.com/jsonhc/p/8179152.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值