在Apple M1中使用crontab时,for循环不起作用
只是一个简单的shell脚本:在Apple M1中使用crontab时,for循环不起作用,cron,apple-m1,Cron,Apple M1,只是一个简单的shell脚本: #/bin/zsh 对于~/Desktop中的文件/* 做 echo${file} 完成 在终端运行时,输出如下: $ ./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
#/bin/zsh
对于~/Desktop中的文件/*
做
echo${file}
完成
在终端运行时,输出如下:
$ ./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
完整磁盘访问权限,而不是crontab
,而不是crontab