【问题标题】:for loop does not work when using crontab in Apple M1在 Apple M1 中使用 crontab 时 for 循环不起作用
【发布时间】:2021-04-25 14:38:52
【问题描述】:

只是一个简单的 shell 脚本:

#!/bin/zsh

for file in ~/Desktop/*
do
    echo ${file}
done

在终端运行时,输出如下:

$ ./test
/Users/onns/Desktop/Screen Shot 2021-04-25 at 19.48.46.png
/Users/onns/Desktop/Screen Shot 2021-04-25 at 19.52.42.png
/Users/onns/Desktop/Screen Shot 2021-04-25 at 19.53.38.png
/Users/onns/Desktop/Screen Shot 2021-04-25 at 19.54.03.png

一切正常,但是当我通过 crontab 测试时,输出是:

/Users/onns/Desktop/test:3: no matches found: /Users/onns/Desktop/*

*在使用crontab时不展开,有谁知道为什么?

cron 任务是:

* * * * * /bin/zsh /Users/onns/Desktop/test >>/Users/onns/Desktop/out.log 2>>/Users/onns/Desktop/err.log

【问题讨论】:

    标签: cron apple-m1


    【解决方案1】:

    修复它。您需要授予cron全盘访问权限,而不是crontab,而不是crontab

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 2013-12-31
      • 1970-01-01
      • 2017-01-14
      • 2011-07-21
      • 2016-02-05
      • 2014-02-16
      相关资源
      最近更新 更多