1.   touch xxx(文件名字).sh

2.      vim xxx.sh 

写入  -----------------------

#!/bin/sh

cd `dirname $0`
pwd
d=`date +%Y%m%d`
d7=`date -d'7 day ago' +%Y%m%d`

cd ../logs/

cp catalina.out catalina.out.${d}
cat /dev/null > catalina.out
rm -rf catalina.out.${d7}

-------------------------           (这个是删除七天以前的log)

路径做对应修改

3.     chmod -R 777 xxx.sh

4.  vim /etc/crontab

  在文件最后 0 2 * * * root /usr/local/wfjb_web_back/xxx.sh

路径对应修改

  重启定时任务 service crond restart
 
-------------------------------------------------------------------------------------------------
https://blog.csdn.net/snihcel/article/details/30248959
https://www.jb51.net/article/101569.htm
(如果catalina.out 清空不再写入            https://www.cnblogs.com/ainihaozhen/p/9466524.html           )