单位自启动脚本 和日志处理等

 

在 /root/ 下建立 2 个文件,一个startup.sh  一个 start 文件(用于自启动)。

vim startup.sh

#!/bin/bash
  
java -jar /root/www/warehouse.jar &

 

vim start

#!/bin/bash
#chkconfig: 2345 10 20
#description: start yunshui-test....


cd /root/
time1=$(date +%Y%m%d-%H%M%S)
nohup ./startup.sh 1>/root/www/logs/access.log 2>/root/www/logs/errors-$time1.log

 

vim splitAccess.sh 自动日志处理,删除20天前的access.log,

#!/bin/sh
#description split logs


time1=$(date -d 'yesterday'  +%Y%m%d)
cp /root/www/logs/access.log /root/www/logs/access-$time1.log
gzip /root/www/logs/access-$time1.log
cat /dev/null > /root/www/logs/access.log

time2=$(date -d '20 day ago' +%Y%m%d)
rm -f /root/www/logs/access-$time2.log.gz

 

vim splitErrors.sh 

 

posted @ 2022-11-30 17:53  琴声清幽  阅读(25)  评论(0编辑  收藏  举报