Automatically delete files from webserver(自动从网络服务器中删除文件)
问题描述
我需要从我的网络服务器中的目录中删除文件,并且我需要一些脚本来自动执行此操作.而且需要满足的条件也很少.
I need to delete files from a directory in my web-server and I need some script to do it automatic. And there is few more conditions which need to be fulfilled.
- 它必须清理目录然后总文件大小超过某些限制,例如 1.5GB
- 该文件将每 24 小时删除一次.
- 不会删除 10 ir 20 mins old 等新文件
- 如果上述所有条件都能同时起作用,那就太棒了.
- It has to clean the directory then total file size exceeds some certain limit for example 1,5GB
- That files would be deleted every 24 hours.
- New files like 10 ir 20 mins old would not be deleted
- It would be just awesome if all of the conditions above would be work at the same time.
对于删除文件,我正在考虑某种玉米任务,但我对它们一无所知,所以这对我来说很棘手.
要删除文件,然后达到一定的限制,我在想某种 PHP 脚本是我的帮助.可能有专门用于这些东西的库.
无论如何,我都会很高兴得到任何帮助.也许我只是需要一些新鲜的想法来为谷歌想出一个正确的关键字;P
For deleting files I was thinking of some kind of corn task but I do not know a thing about them so it is tricky for me.
To delete files then a certain limit is reached I was thinking that some kind of PHP script my help. May be there is a library meant for these things.
Any way I will be very happy for any kind of help. May be I just need some fresh thoughts to come up with a right keyword for google ;P
我的服务器在 linux 上运行.
My server runs on linux.
推荐答案
如果你的服务器运行的是 linux,cron
作业是最好的选择.只需编写一个脚本来检查您提到的条件(使用例如 stat
和其他一些工具)并在适用时删除文件,并将 crond
设置为每 24 小时运行一次.这里是cron
的简短介绍.
If your server is running linux, a cron
job is the best option. Simply write a script that checks the conditions you mention (using e.g. stat
and some other tools) and deletes the file if they apply, and set crond
to run it every 24 hours. Here's a short introduction to cron
.
在 Windows 上,您可以使用脚本和计划任务执行类似的操作.
On Windows, you'd do something similar with a script and a scheduled task.
这篇关于自动从网络服务器中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自动从网络服务器中删除文件
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01