目录
cut_logs.sh
#!/bin/bash
access_log_path=/usr/local/nginx/logs/access.log
error_log_path=/usr/local/nginx/logs/error.log
access_save_path=/usr/local/nginx/logs/Historical_logs/access_$(date +%Y%m%d -d 'yesterday').log
error_save_path=/usr/local/nginx/logs/Historical_logs/error_$(date +%Y%m%d -d 'yesterday').log
cp $access_log_path $access_save_path && echo > $access_log_path
cp $error_log_path $error_save_path && echo > $error_log_path
yum install crontabs
crontab -e
#输入
#0 0 * * * /usr/bin/sh cut_logs.sh #每天的00:00执行日志切分
crontab -l
service crond restart