---
title: "shell 定时清理日志"
author: "hotsmile"
date: "2013-07-31T13:57:16Z"
tags: ["Date", "shell"]
categories: ["编程语言"]
slug: "shell"
draft: false
lastmod: "2013-07-31T13:57:16Z"
id: 1916030
url: "https://hotsmile.iteye.com/blog/1916030"
---

#!/bin/bash

source ~/.bash\_profile

file\_base=/mstms/apms  
posp\_file=/mstms/POSP

filedate1=\`date -d "-30 days" +%F\`

filedate2=\`date -d "-30 days" +%Y%m%d\`

cd $file\_base  
find ./ -name \*"$filedate1"* -exec rm -rf {} \\;  
find ./ -name \*"$filedate2"* -exec rm -rf {} \\;

cd $posp\_file  
find ./ -name \*"$filedate1"* -exec rm -rf {} \\;  
find ./ -name \*"$filedate2"* -exec rm -rf {} \\;

cd ~  
find ./ -name \*"$filedate1"* -exec rm -rf {} \\;  
find ./ -name \*"$filedate2"* -exec rm -rf {} \\;