我正在尝试在修改日志文件 30 天后清除日志文件。 我想在 unix/linux 中使用 find 命令而不是 php 中的 glob 来利用从系统而不是通过 php 调用它的优势。 如果我以这种方式运行它,它会迭代所有文件吗?
这是我到目前为止所拥有的:
<?php
shell_exec ('find /path/to/file/*') -mtime +30 -delete;
?>
shell_exec ('find /path/to/file/*') -mtime +30 -delete;
^^--move this
应该是
shell_exec ('find /path/to/file/* -mtime +30 -delete');
^^---to here
正如所写,PHP将其视为:
take the return value of shell_exec,
subtract the undefined constant mtime,
add integer 30,
subtract the undefined constant delete