shell日志切割

shell日志切割

#!/bin/sh
#filename=log.sh
log_path="" #日志记录的目录地址
log_file="test.log" #默认日志文件名称
log_path_new=${log_path}$(date +%Y)/$(date +%m)/
sudo mkdir -p ${log_path_new}
sudo mv ${log_path}${log_file} ${log_path_new}$(date +%Y_%m_%d).logs
sudo touch ${log_path}${log_file}

 

你可能感兴趣的:(shell日志切割)