简体   繁体   English

crontab没有删除Linux中的文件

[英]crontab is not deleting the files in linux

I am trying to delete all the pdf files which are more than 30 days old at 11:30 PM 我正在尝试删除11:30 PM超过30天的所有pdf文件

I added the below given code in crontab 我在crontab中添加了以下给定的代码

30 23 * * * find /var/www/html/site/reports/ -name "*.pdf" -type f -mtime +30 | xargs -I {} rm -f {} \;

But it doesn't delete the files. 但是它不会删除文件。

Can you please check what the issue is? 您能检查一下问题是什么吗?

The crontab details crontab的详细信息

-rw-r--r--. 1 root root 532 Sep 30 11:14 crontab

One of the files which i need to delete 我需要删除的文件之一

-rw-r--r-- 1 apache apache 15215 Jul 25 11:24 sales_report.pdf

You missed user and PATH. 您错过了用户和PATH。 This may help 这可能会有所帮助

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

30 23 * * * root find /var/www/html/site/reports/ \( -name "*.pdf" \) -type f -mtime +30 -exec rm {} \; >> /tmp/debug_cron 2>&1

And then check /tmp/debug_cron 然后检查/ tmp / debug_cron

我有这个工作的Linux盒子。

30 23 * * * find /var/www/html/site/reports/ \( -name "*.pdf" \) -type f -mtime +30 -exec rm {} \;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM