编写备份脚本

#!bin/bash
#切分nginx日志

#目录
BASE_DIR=/usr/local/nginx
#文件名
BASE_FILE_NAME=access.log


#原日志目录
HOME_PATH=$BASE_DIR/logs
#备份日志目录
BAK_PATH=$BASE_DIR/datalogs


#原文件
HOME_FILE=$HOME_PATH/$BASE_FILE_NAME
#备份文件名
BAK_FILE=$BAK_PATH/$date-$BAK_FILE_NAME


echo $BAK_FILE
#停止nginx服务
$BASE_DIR/sbin/nginx -s stop

#移动原文件到目标文件

mv $HOME_FILE $BAK_FILE
#启动nginx服务
$BASE_DIR/sbin/nginx</pre>

创建定时任务

Last modification:July 27th, 2020 at 05:21 pm
If you think my article is useful to you, please feel free to appreciate