find 命令删除日志文件
find ./my_dir -mtime +10 -type f -delete
EXPLANATIONS
./my_diryour directory (replace with your own)-mtime +10older than 10 days-type fonly files-deleteno surprise. Remove it to test yourfindfilter before executing the whole command
And take care that ./my_dir exists to avoid bad surprises !
https://stackoverflow.com/a/13489511/8025086
find /mylog/path -mindepth 1 -mtime +5 -delete
-mindepth 1means process all files except the command line arguments.-mtime +5will check for the files modified 5 days ago.-deletewill delete
https://unix.stackexchange.com/a/459997
浙公网安备 33010602011771号