1.判断文件夹是否存在

#!/bin/sh

workspace="/home/web/mall"

#如果文件夹不存在
if [ ! -d ${workspace} ]; then
echo "is not exists"
else
echo "is exists"
fi

2.切分nginx日志

 #!/bin/bash
#function:cut nginx log files for lnmp v0. and v0. #set the path to nginx log files
log_files_path="/home/www/wwwlogs/"
backup_files_path="/alidata1/logs/nginx/" log_files_dir=${backup_files_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/$(date -d "yesterday" +"%d") if [ ! -d ${log_files_dir} ]; then
mkdir -p $log_files_dir
fi #set nginx log files you want to cut
log_files_name=(access nginx_error wechat.51ekt.com mall.51ekt.com shop.51ekt.com api.51ekt.com.log)
#set the path to nginx.
nginx_sbin="/usr/local/nginx/sbin/nginx"
#Set how long you want to save
save_days= ############################################
#Please do not modify the following script #
############################################ log_files_num=${#log_files_name[@]} #cut nginx log files
for((i=;i<$log_files_num;i++));do
log=${log_files_path}${log_files_name[i]}.log
if [ -f ${log} ];then
mv ${log_files_path}${log_files_name[i]}.log ${log_files_dir}/${log_files_name[i]}_$(date -d "yesterday" +"%Y%m%d").log
fi
done #delete days ago nginx log files
#find $log_files_path -mtime +$save_days -exec rm -rf {} \; $nginx_sbin -s reload

最新文章

  1. 动态添加和更改F7编辑器(div和editGrid列)
  2. java-类
  3. CSS元素类型
  4. Linux命令 ,在当前目录下查找一个,或者多个文件
  5. iOS 开发者必不可少的 75 个工具,你都会了吗
  6. NGINX的奇淫技巧 —— 5. NGINX实现金盾防火墙的功能(防CC)
  7. 李洪强iOS开发之OC[018]对象和方法之间的关系
  8. 熟悉Git使用
  9. js验证日期
  10. Math.floor(Math.random()*3+1)
  11. 价值1.35亿美元的BUG
  12. FreeBSD常用操作
  13. 论文阅读笔记十八:ENet: A Deep Neural Network Architecture for Real-Time Semantic Segmentation(CVPR2016)
  14. poj2151--Check the difficulty of problems(概率dp第四弹,复杂的计算)
  15. OPENGL NEHE Lesson11 11课的计算公式推导
  16. GAutomator,GAutomatorview和Android SDK,Unity配置
  17. QT开发(十二)——QT事件处理机制
  18. excel表中同一列相同内容进行合并
  19. HDU-2665-Kth number(划分树)
  20. DataBase 之 数据库设计六大范式

热门文章

  1. dockerfile构建nginx并结合php
  2. mysql / pgsql 使用sql语句查询数据库所有表注释已经表字段注释
  3. window 服务
  4. 如何安装和配置RabbitMQ(转载)
  5. linux文件和目录的删除、新建、移动等操作
  6. 通过日志恢复SQL Server的历史数据
  7. slot 插槽的使用
  8. 云笔记项目-测试时无法连接MySQL Server
  9. 径向模糊(Radial Blur)
  10. propTypes