gpt4 book ai didi

linux - Cron 压缩文件

转载 作者:太空宇宙 更新时间:2023-11-04 11:39:47 27 4
gpt4 key购买 nike

我想介绍一个 Cron tak,它将使用以下规则“gzip”文件:

  1. 在名为“/log”的文件夹中找到文件(可以位于文件系统中的任何位置)和

  2. gzip 文件,超过 2 天,文件名句柄中有“./log

我已经编写了下面的脚本 - 它不起作用 - 我关闭了吗?需要什么才能让它发挥作用?谢谢。

/usr/bin/find ./logs -mtime +2 -name "*.log*"|xargs gzip

最佳答案

在我的 crontab 中,我调用:

/usr/sbin/logrotate -s ~/.logrotate/status ~/.logrotate/logrotate.conf

在我的 ~/.logrotate/logrotate.conf 中:

# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

## compression

# gzip(1)
#compresscmd /usr/bin/gzip
#compressoptions -9
#uncompresscmd /usr/bin/gunzip
#compressext .gz

# xz(1)
compresscmd /usr/bin/xz
uncompresscmd /usr/bin/xzdec
compressext .xz

/home/h3xx/.log/*.log /home/h3xx/.log/jack/*.log {
# copy and truncate original (for always-open file handles
# [read: tail -f])
copytruncate

# enable compression
compress
}

/home/h3xx/.usage/*.db {
# back up databases
copy

# enable compression
compress
}

关于linux - Cron 压缩文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4495266/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com