Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

cron - Crontab没有运行我的脚本。 卡塔琳娜(Crontab is not running my script. Catalina)

I just have started to use crontab and have some problems with it.

(我刚刚开始使用crontab,并且有一些问题。)

I have already read some posts about how to use it on macOS, but it still not working.

(我已经阅读了一些有关如何在macOS上使用它的文章,但仍然无法正常工作。)

So, my task is very easy: I write crontab -e, then edit it to */1 * * * * cliclick -w 1 m:3,3 (for example) - which mean repeat every 1 min.

(因此,我的任务非常简单:我编写crontab -e,然后将其编辑为*/1 * * * * cliclick -w 1 m:3,3 (例如)-这意味着每1分钟重复一次。)

And nothing has changed.

(一切都没有改变。)

But, when I use just this command from terminal everything is ok.

(但是,当我仅从终端使用此命令时,一切正常。)

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

(我已经尝试创建一个script.sh文件,并且存在相同的情况:从手动命令起作用,而从crontab则不起作用。)

By the way, if I use simple command, for example echo it isn't working too.

(顺便说一句,如果我使用简单的命令,例如echo,它也无法正常工作。)

Maybe, I do something wrong, please help me.

(也许我做错了,请帮助我。)

PS: Full access to disk crontab has.

(PS:具有对crontab磁盘的完全访问权限。)

Thank you!

(谢谢!)

  ask by Sergey translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can check if there are any errors while running the cron by configuring it as below.

(您可以通过以下配置在运行cron时检查是否有任何错误。)

*/1 * * * * cliclick -w 1 m:3,3 >> output.log 2>&1

the last part 2>&1 will redirect the STDERR to the output.log as well.

(最后一部分2>&1也将STDERR重定向到output.log。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...