问题
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.
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.
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.
By the way, if I use simple command, for example echo it isn't working too.
Maybe, I do something wrong, please help me.
PS: Full access to disk crontab has.
Thank you!
回答1:
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
See this blog post: https://blog.bejarano.io/fixing-cron-jobs-in-mojave/
回答2:
You can check if there are any errors while running the cron by configuring it as below.
*/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.
回答3:
You need to authorize Full Disk Access for terminal.app in Settings>Security & Privacy>Privacy.
来源:https://stackoverflow.com/questions/59123499/crontab-is-not-running-my-script-catalina