简体   繁体   English

Linux cron作业覆盖文件

[英]Linux cron job overwrite file

如果cron作业创建具有常量名称的存档,则存档将在下一个cron作业中替换为新存档,或者因具有此名称的文件已存在而终止?

There's no magic in cron - it just runs a program at a given timing. cron没有魔法 - 它只是在给定的时间运行一个程序。 If that program has the logic to check if the archive exists, it will still have it when run via as a cron job. 如果该程序具有检查存档是否存在的逻辑,则在作为cron作业运行时它仍将具有该存档。 If it just overwrites the archive, it will continue doing so when run as a cron jbo. 如果它只是覆盖存档,它将在作为cron jbo运行时继续这样做。

Cron just run your command, so it's up to you how this command may look. Cron只是运行你的命令,所以由你来决定这个命令的外观。 For example: 例如:

0 8 * * * rm -rf arc.zip && zip -r arc.zip /tmp

This cron runs every day at 8am and performs next steps: 这个cron每天早上8点运行并执行后续步骤:

  1. remove file arc.zip 删除文件arc.zip
  2. create new archive arc.zip from /tmp directory /tmp目录创建新的存档arc.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM