使用 cron 作业定期清除 phpThumb 缓存

发布于 2024-09-16 04:45:13 字数 490 浏览 3 评论 0原文

我在客户端网站上使用 phpThumb,由于它是一个图像非常重的应用程序,因此缓存很快就会变得巨大。今天,拇指停止工作,我重命名了缓存文件夹,因为该文件夹太大,无法通过 ftp 删除。我将其重命名为cache_old,现在尝试通过 ssh 删除它。我重新创建了缓存文件夹,一切都恢复正常。

由于当缓存文件夹太满时它似乎会停止工作,而且为了保持服务器整洁,我想设置一个每日 cron 作业来清除缓存文件夹中的文件。我不知道如何做到这一点,但还没有找到答案。

缓存文件夹中有一个名为index.php的文件,我认为需要保留它,再加上一个名为source的子文件夹,它又有一个名为index.php的文件,我再次认为需要在那里。所以我需要一个命令来删除除这些文件之外的所有内容。

任何有关如何设置的指导将不胜感激!

谢谢, 克里斯汀

·P.S.该网站托管在 DreamHost 上,我已经通过 cronjob 面板设置了其他作业,并且如果设置更容易的话,我确实具有 SSH 访问权限。干杯!!

I am using phpThumb on a client website, and as it is a very image heavy application the cache gets huge quick. Today the thumbs stopped working and I had rename the cache folder, as the folder was too big to delete via ftp. I renamed it cache_old and am trying to delete it now via ssh. I recreated the cache folder and everything worked fine again.

Since it seems it stops working when the cache folder is too full, plus just to keep the server tidy, I would like to setup a daily cron job to clear files from the cache folder. I have no idea how to do this though and haven't been able to find an answer yet..

The cache folder has a file in it called index.php which I assume needs to stay, plus a sub folder called source, which again has a file called index.php, again I assumed that needs to be there. So I need a command that will delete everything BUT those files.

Any guidance on how to set this up would be appreciated!

Thanks,
Christine

P.S. The site is hosted on DreamHost, and I have set other jobs up via there cronjob panel, and I do have SSH access if setting it up that way is easier. Cheers!!

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

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

发布评论

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

评论(1

悲念泪 2024-09-23 04:45:13

可以用一个命令来完成此操作,但更明显。

 rm `find /path_to_cache_folder/ -type f | grep -v 'index.php'`
 rm `find /path_to_cache_folder/source -type f | grep -v 'index.php'`

或者在一个 cron 作业中

rm `find /path_to_cache_folder/ -type f | grep -v 'index.php'` && rm `find /path_to_cache_folder/source -type f | grep -v 'index.php'`

it's possible to do this in one command but it's more obviously.

 rm `find /path_to_cache_folder/ -type f | grep -v 'index.php'`
 rm `find /path_to_cache_folder/source -type f | grep -v 'index.php'`

or in one cron job

rm `find /path_to_cache_folder/ -type f | grep -v 'index.php'` && rm `find /path_to_cache_folder/source -type f | grep -v 'index.php'`
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文