zoukankan      html  css  js  c++  java
  • linux 定期清除日志

    clearLog.sh

      #!/bin/sh
      find /usr/local/apache/logs -mtime + 30 -name "*.log" -exec rm {} ;

        说明:

      1. find:Linux查找命令,用户查找指定条件的文件
      2.  /usr/local/apache/logs:需要进行清理的目标目录
      3.  -mtime:标准语句写法
      4.  +30 :数字代表天数   选中30天外的数据
      5.  -name "*.log":目标文件名
      6.  -exec:固定写法 执行rm命令
      7.  rm :强制删除包括目录在内的文件
      8.  {} ;:固定写法,一对大括号+空格++;

    chmod +x clearLog.sh

    crontab 启动定时任务

    转载于:https://www.cnblogs.com/lizhang4/p/9283333.html

  • 相关阅读:
    UESTC
    Education Round 8 A
    Gym
    Gym
    hdoj 1159 Common Subsequence
    UVA
    UESTC
    51Nod 1068 Bash游戏 V3 (这规律不好找)
    51Nod 1066 Bash游戏
    51Nod 1002 数塔取数问题
  • 原文地址:https://www.cnblogs.com/twodog/p/12136528.html
Copyright © 2011-2022 走看看