定时“cp *.html”在 OSX 上忽略新文件
我有一个定时的“cp *.html”命令,每分钟在 OSX 机器上运行一次。源文件从数据库重新生成并写入源目录就好了。 cp 命令通常会拾取它们并刷新 /Library/WebServer/Documents 中的副本(这是一个快速而肮脏的内部网站,用于监视我们的进程之一 - 我们不想花费任何额外的周期来维护应用程序服务器或任何类似的东西,所以我们只是使用 OSX 的内置 Apache 副本和默认设置。)
我们注意到,当我们将新的 foo.html 页面添加到源目录时, cronned cp 命令不会开始复制它直到我们手动复制它一次,即使它与 *.html 模式匹配。这看起来很疯狂。权限和所有权都以相同的方式设置(rw-r--r-- 对于两个目录中的所有内容)。
有什么想法吗?如果我无法弄清楚出了什么问题,我可能会重写它以使用 rsync,但这似乎是一种逃避。
I have a cronned "cp *.html" command that runs every minute on an OSX box. The source files are regenerated from a database and written to the source directory just fine. The cp command usually picks them up and refreshes the copies in /Library/WebServer/Documents (this is for a quick-and-dirty internal website that monitors one of our processes - we don't want to spend any extra cycles maintaining an appserver or anything similar, so we're just using OSX's built-in copy of Apache with default settings.)
We've noticed that when we add a new foo.html page to the source directory, the cronned cp command does not begin copying it over until we manually copy it once, even though it matches the *.html pattern. This seems crazy. Permissions and ownership all are set the same way (rw-r--r-- for everything in both directories).
Any ideas? If I can't figure out what is going wrong, I'll probably rewrite it to use rsync, but that seems like a cop-out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定,但看起来 cron 仅扩展 '*' 一次(也许在第一次调用时?)。尝试将其用作命令:
这样您的通配符每次都会从头开始扩展。
I'm not sure, but it looks like cron is expanding '*' only once (maybe at the first invocation?). Try using this as a command:
This way your wildcards will be expanded every time from scratch.