本文介绍了Crontab 没有运行 local/bin/脚本.卡特琳娜,比格苏尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 crontab 并且遇到了一些问题.我已经阅读了一些关于如何在 macOS 上使用它的帖子,但它仍然无法正常工作.

I just have started to use crontab and have some problems with it. I have already read some posts about how to use it on macOS, but it still not working.

所以,我写 crontab -e,然后编辑它*/1 * * * * cliclick -w 1 m:3,3(例如) - 这意味着每 1 分钟重复点击 x=3;y=3.一切都没有改变.但是,当我从终端仅使用此命令时,一切正常.

So,I write crontab -e, then edit it to*/1 * * * * cliclick -w 1 m:3,3 (for example) - which mean repeat click in x=3;y=3 every 1 min.And nothing has changed.But, when I use just this command from the terminal everything is ok.

我已经尝试创建一个 script.sh 文件,同样的情况:手动命令它有效,而 crontab 无效.

I have already tried to create a script.sh file, and the same situation: from hand-command it works, and from crontab isn't.

也许,我做错了什么?更新:crontab 具有完整磁盘访问权限.

Maybe, I do something wrong?UPDATE: Full disk access crontab has.

更新 2:我试着在 BigSur 上再做一次.首先我使用了一个更简单的命令,比如 echo:

UPDATE2:I tried do it again on the BigSur. First of all I use a more simple command like echo:

* * * * * echo 'test' >>/*/桌面/text.txt它运作良好.之后,我编写了自己的script.sh

* * * * * echo 'test' >> /*/Desktop/text.txtAnd it works well. After that, I write my own script.sh

echo '2test' >> /Users/***/Desktop/t.txt
/usr/local/bin/cliclick -w 1 m:1,3
cliclick -w 1 m:55,44

并且 cliclick 不起作用,因为位于 /usr/local/bin/ 中的其他 bin 文件(cliclick 位于此路径中)

And it the cliclick not working, as the other bin files located in /usr/local/bin/ (cliclick located in this path)

请注意,如果我执行 ./script.sh,则 cliclick 在这两种情况下都可以正常工作.

Note, that if I execute ./script.sh then cliclick works fine in both cases.

我彻底搜索了一下,发现虽然 crontab:https://github.com/BlueM/cliclick/issues/103

I thoroughly googled and found that run cliclick (and other) is NOT possible though crontab: https://github.com/BlueM/cliclick/issues/103

推荐答案

我的问题是,cron 无法访问磁盘,因此无法运行我的脚本.我必须为 /usr/sbin/cron

My Problem was, that cron had no access to the Disk, so it couldn't run my script. I had to give Full Disk Access for /usr/sbin/cron

请参阅此博文:https://blog.bejarano.io/fix-cron-jobs-in-mojave/

这篇关于Crontab 没有运行 local/bin/脚本.卡特琳娜,比格苏尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 22:50