许吉友 - 运维

删除脚本

删除一天前的文件:

#!/bin/bash

start=$(date +%y-%m-%d-%H%M%m)
echo $start

File=/temp/delete_$start.txt
FilePath=/nsm/moloch/raw

echo $File
echo $FilePath

day=1

echo "输出日志文件:"
echo "sudo find $FilePath -mtime +$day -name '*.pcap' > $File"
sudo find $FilePath -mtime +$day -name '*.pcap' > $File

echo "删除日志文件:"
echo "sudo find $FilePath -mtime +$day -name '*.pcap' -exec rm -rf {} \;"
sudo find $FilePath -mtime +$day -name '*.pcap'  -exec rm -rf {} \;