你的位置:首页 > 编程开发 > Shell
#!/bin/bash #function:cut nginx log files for lnmp #author: Lorock.Xu #set the path to nginx log files log_files_path="/data/wwwlogs/" log_files_dir=${log_files_path} #set nginx log files you want to cut log_files_name=(www.601849.com_nginx) #set the path to nginx. nginx_sbin="/usr/local/nginx/sbin/nginx" #Set how long you want to save save_days=180 ############################################ #Please do not modify the following script # ############################################ #mkdir -p $log_files_dir log_files_num=${#log_files_name[@]} #cut nginx log files for((i=0;i<$log_files_num;i++));do mv ${log_files_path}${log_files_name[i]}.log ${log_files_dir}${log_files_name[i]}_$(date -d "yesterday" +"%Y-%m-%d").log done #delete 180 days ago nginx log files find $log_files_path -mtime +$save_days -exec rm -rf {} \; $nginx_sbin -s reload
Tags:nginx shell 日志
尊重共享,欢迎转载,请自觉添加本文链接,谢谢!本文链接:https://www.601849.com/post/354.html
相关文章
- nginx日志分割shell 6个月前 (11-05)
- scp通过特定端口从远程服务器下载文件到本机 6个月前 (11-01)
- Windows批处理之FOR语句祥解 9个月前 (07-16)
- Shell编程中dialog的使用方法 10个月前 (06-14)
- Shell字符串比较相等、不相等方法小结 11个月前 (06-02)
- 合并一个文件夹下多个文件内容的单行shell命令 11个月前 (05-25)
- Shell命令关闭不需要的随机启动服务 11个月前 (05-25)
- Linux shell常用的73条命令总结 11个月前 (05-25)
- linux批量杀进程的shell脚本 11个月前 (05-12)
- 检测MYSQL运行是否正常 11个月前 (05-11)
- 上一篇:获取网站运行状态脚本
- 下一篇:linux批量杀进程的shell脚本
发表评论: