Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 用于删除crontab中不工作的文件的Shell命令_Bash_Shell_Ubuntu_Cron - Fatal编程技术网

Bash 用于删除crontab中不工作的文件的Shell命令

Bash 用于删除crontab中不工作的文件的Shell命令,bash,shell,ubuntu,cron,Bash,Shell,Ubuntu,Cron,我有一个命令,可以使用crontab定期删除旧文件 命令是: 0 * * * * sudo find /path/to/data/ -type f -mmin +600 -name '*.gz' -execdir rm -- '{}' +; 这有助于我从给定文件夹位置删除所有超过600分钟(10小时)的.gz文件。它可以在命令提示符和crontab中完美地工作 0 * * * * sudo find /path/to/data/ -type f -mmin +600 -name '*.gz%%

我有一个命令,可以使用
crontab
定期删除旧文件

命令是:

0 * * * * sudo find /path/to/data/ -type f -mmin +600 -name '*.gz' -execdir rm -- '{}' +;
这有助于我从给定文件夹位置删除所有超过600分钟(10小时)的
.gz
文件。它可以在命令提示符和crontab中完美地工作

0 * * * * sudo find /path/to/data/ -type f -mmin +600 -name '*.gz%%' -execdir rm -- '{}' +;
现在我修改了上面的命令来删除另一组文件。但是,它可以在命令提示符下工作,但不能在crontab中工作

0 * * * * sudo find /path/to/data/ -type f -mmin +600 -name '*.gz%%' -execdir rm -- '{}' +;
我的文件扩展名为
*.gz%%
。文件名已附加
%%
,如果需要,可以更改为其他字符

如果从命令提示符运行,命令运行得非常好,但是保存在
crontab
中时根本不会执行。

crontab似乎无法执行该命令。任何要调试的指针或命令中的问题是什么?

来自
crontab(5)
手册页:


看起来是这样。我不能马上接受答案。只要允许,我会做的。