Created
February 23, 2022 01:56
-
-
Save consatan/a4e48eb8808148dcd25efa5fb20e9c65 to your computer and use it in GitHub Desktop.
find by mtime older than today midnight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# v.a. https://unix.stackexchange.com/a/257966 | |
# -daystart -mtime +0 表示文件的 mtime 时间在当天 0 点前(用于保留最新的一个文件) | |
# 如果没有 -daystart 的话,表示 文件的 mtime 时间在 24 小时前(用于保留最新的2个文件) | |
find ./ -maxdepth 1 -type f -name '*.log' -daystart -mtime +0 -exec gzip {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment