gpt4 book ai didi

linux - 这个命令到底在做什么?

转载 作者:太空宇宙 更新时间:2023-11-04 05:38:25 24 4
gpt4 key购买 nike

我正在尝试在其他服务器中重现日志 gzip cron,

我拥有的"template"是:

00 02 * * * cd ~/project_folder/application/logs; find . -type f -name "*.php" -mtime +4 -exec gzip {} \;

这个 gzip 每天都会在该目录中压缩 .php 并删除未压缩的文件吗?

最佳答案

您可以访问https://crontab-generator.org/它是生成 crontab 行的好工具,您将了解数字和星号的含义。现在如果你选择

  • 0 分钟
  • 凌晨 2 点一小时
  • 保持其他一切不变
  • 对于命令使用 cd ~/project_folder/application/logs; find . -type f -name "*.php" -mtime +4 -exec gzip {} \;

然后单击生成 crontab 行,您将看到其运行时间的示例。另外,它还会添加这个卡盘 >/dev/null 2>&1不用担心,它是命令的输出指令,最好将它放在 crontab 中。

enter image description here

The argument to -mtime is interpreted as the number of whole days in the age of the file. -mtime +n means strictly greater than, -mtime -n means strictly less than.

所以这个命令将找到并压缩所有 *.php文件的最新修改时间 ( mtime ) 大于 4 天。

编辑:我不记得-k gzip 的参数也。因此按照 @chang-qian回复。

Without -k, gzip implies that it will delete the original files after their compression.

关于linux - 这个命令到底在做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47154132/

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