Board logo

标题: [求助] 遇到一个很奇怪的问题:命令在.sh文件中执行报错! [打印本页]

作者: gump    时间: 2019-6-6 15:43     标题: 遇到一个很奇怪的问题:命令在.sh文件中执行报错!

  1. /bin/find /www/wdlinux/apache/logs/access*log* -mtime +10 -exec rm -rf {} \;
复制代码

以上这条命令在shell中直接执行并没有问题,但是把它放到auto-del-apache_log.sh文件中,再通过
  1. sh -x auto-del-apache_log.sh
复制代码

在shell中执行结果报错:
  1. + /bin/find /www/wdlinux/apache/logs/access_log-20190520 /www/wdlinux/apache/logs/access_log-20190521 /www/wdlinux/apache/logs/access_log-20190522 /www/wdlinux/apache/logs/access_log-20190523 /www/wdlinux/apache/logs/access_log-20190524 /www/wdlinux/apache/logs/access_log-20190525 /www/wdlinux/apache/logs/access_log-20190526 /www/wdlinux/apache/logs/access_log-20190527 /www/wdlinux/apache/logs/access_log-20190528 /www/wdlinux/apache/logs/access_log-20190529 /www/wdlinux/apache/logs/access_log-20190530 /www/wdlinux/apache/logs/access_log-20190531 /www/wdlinux/apache/logs/access_log-20190601 /www/wdlinux/apache/logs/access_log-20190602 /www/wdlinux/apache/logs/access_log-20190603 /www/wdlinux/apache/logs/access_log-20190604 'www/wdlinux/apache/logs/access_log-20190605 /www/wdlinux/apache/logs/access_log-20190606 -mtime +10 -exec rm -rf '{}' ';
  2. /bin/find: missing argument to `-exec'
复制代码


请问是何原因呢?
作者: admin    时间: 2019-6-26 09:51

不要加-x试试




欢迎光临 WDlinux官方论坛 (http://www.wdlinux.cn/bbs/) Powered by Discuz! 7.2