“--delete-after”的目的是什么? wget 的选项?

发布于 2024-12-02 16:19:42 字数 108 浏览 0 评论 0原文

当我阅读 wget 的联机帮助页时,我遇到了“--delete-after”选项? 提供这样一个选项的目的是什么?只是为了测试页面是否可以下载?或者也许还有其他情况这个选项有用,希望大家能给我一些提示。

I came across the "--delete-after" option when I was reading the manpage of wget ?
what's the purpose of providing such an option ? Is it just for testing the page is ok for downloading ? Or maybe there are other situations where this option is useful, I hope you guys may give me some hints.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

寄居人 2024-12-09 16:19:42

参考您上面的评论。我将提供一些我们如何使用它的示例。我们有一些网站在 Rackspace 云站点上运行,这是一种托管云托管解决方案。我们无法访问常规的 cron。

我们在使用 WordPress 的网站上遇到了使用失控的问题,因为 WP 不断调用 wp-cron.php。为了给您一种使用失控的感觉,它在一天内用完了一个月分配的 CPU 周期。无论如何,我所做的是禁用 WordPress 系统中调用 wp-cron.php 并通过 wget 手动调用它。我对过程的输出不感兴趣,所以如果我不使用 --delete-after 和 wget (wget ... > /dev/null 2>&1 效果很好也)wget 运行的文件夹将充满数百个无用的日志和每次调用脚本时的输出。

我们还安装了 SugarCRM,并且该系统需要调用其 cron 脚本来处理系统维护。我们也默默地使用 wget 来实现这一点。基本上,许多此类基于 Web 的系统都有 cron 脚本。如果您无法直接在计算机上使用 php 调用脚本,那么另一个选项是使用 wget 静默调用它。

调用这些 cron 脚本的命令非常基本 - wget --delete-after http ://example.com/cron.php?parameters=if+needed

With reference to your comments above. I'm providing some examples of how we use it. We have a few websites running on Rackspace Cloud Sites which is a managed cloud hosting solution. We don't have access to regular cron.

We had an issue with runaway usage on a site using WordPress because WP kept calling wp-cron.php. To give you a sense of runaway usage, it used up in one day the allotted CPU cycles for a month. Anyway what I did was disable wp-cron.php being called within the WordPress system and manually call it through wget. I'm not interested in the output from the process so if I don't use --delete-after with wget (wget ... > /dev/null 2>&1 works well too) the folder where wget runs would get filled with hundreds of useless logs and output of each time the script was called.

We also have SugarCRM installed and that system requires its cron script to be called to handle system maintenance. We use wget silently for that as well. Basically a lot of these kinds of web-based systems have cron scripts. If you can't call your scripts directly say using php on the machine then the other option is calling it silently with wget.

The command to call these cron scripts is quite basic - wget --delete-after http://example.com/cron.php?parameters=if+needed

柠檬色的秋千 2024-12-09 16:19:42

我正在使用 wget (带有 cron)来自动执行 Web 应用程序的命令,因此我对页面的内容不感兴趣。 --delete-after 非常适合此目的。

I'm using wget (with cron) to automate commands to a web application, so I have no interest in the contents of the pages. --delete-after is ideal for this.

霞映澄塘 2024-12-09 16:19:42

您可以使用它来测试页面是否可以正常下载,但通常它用于强制代理服务器缓存其内容。

如果您所在的连接上有一个网络设备缓存站点和端点之间的内容,并且您有一个在该网络上的用户中很受欢迎的站点,那么作为系统管理员,您可能想要做的是使用下层机器在代理之后编写递归“-r”或镜像“-m”wget 操作的脚本。

代理设备将看到这一点并预先缓存该站点及其资产,从而使在所述代理之后使用的站点访问速度更快一些。

然后,您需要指定“--delete-after”以释放所使用的磁盘空间,除非您想保留强制缓存的所有站点的本地副本。

You can use it for testing if a page is downloading ok, but usually it's used to force proxy servers to cache their contents.

If your sitting on a connection where there's a network appliance caching content between the site and your endpoint, and you have a site that's popular among users on that network, then what you may want to do as a sysadmin, is to use a down level machine just after the proxy to script a recursive "-r" or mirror "-m" wget operation.

The proxy appliance will see this and pre-cache the site and it's assets, thus making site accesses for uses after said proxy a bit faster.

You'd then want to specify "--delete-after" to free up the disk space used unless your wanting to keep a local copy of all sites you force to cache.

末骤雨初歇 2024-12-09 16:19:42

有时,您只需要访问网站即可设置 IP 地址 - 比如说,如果您正在使用自己的 dyn dns 服务。

Sometimes you only need to visit a website to set an IP address - say if you are rolling your own dyn dns service.

回眸一笑 2024-12-09 16:19:42

我们有一些在 WP Engine 上运行的 WordPress 网站,我使用 wget -r --spider 来构建服务器端缓存。 --spider 不下载任何东西,但它确实创建了我不需要的目录。因此添加 --delete-after

We've got some WordPress sites running on WP Engine and I'm using wget -r --spider to build out the server side cache. --spider doesn't download anything but it does create directories which I don't need. Hence adding on --delete-after

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文