doukang7858 2010-08-11 16:42 采纳率: 0%
浏览 384

自动从Web服务器删除文件

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.

  • 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.

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

EDIT: My server runs on linux.

  • 写回答

4条回答 默认 最新

  • dongzhiqi0332 2010-08-11 16:54
    关注

    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.

    On Windows, you'd do something similar with a script and a scheduled task.

    评论

报告相同问题?

悬赏问题

  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题