【发布时间】: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
【问题讨论】: