Crontab没有运行本地/bin/脚本.卡塔利娜(BigSur) [英] Crontab is not running local/bin/ script. Catalina, BigSur

查看:94
本文介绍了Crontab没有运行本地/bin/脚本.卡塔利娜(BigSur)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用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.

UPDATE2:我尝试在BigSur上再做一次.首先,我使用一个更简单的命令,例如 echo :

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

* * * * * echo'test'>>/*/Desktop/text.txt 而且效果很好.之后,我编写了自己的 script.sh

* * * * * echo 'test' >> /*/Desktop/text.txt And 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无法正常工作,因为其他bin文件位于/usr/local/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.

我对Google进行了彻底搜索,发现通过 crontab 可以不能进行cliclick(和其他操作):

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-mojave/

这篇关于Crontab没有运行本地/bin/脚本.卡塔利娜(BigSur)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆