Search code examples
terminalcron

"Terminal" would like to administer your computer. Administration can include passwords


I am trying to automate crontab addition in Mac Catalina 10.15.5 via command:

echo -e "* * * * * \run.sh"|crontab -

this command replicates crontab -e command and adds the required crontab in the system.

But it asks for permission which is not removable via automation.

enter image description here

a. Sudo command requires user to enter password, which is again not possible to be automated.

b. Tried creating a file and then adding it to crontab via crontab filepath, but that also requires above elevation.


Solution

  • Unfortunately, latest Mac OS have put additional layer of security and can't be bypassed.

    But I found following workaround. Since I am not changing system, so following solution works for me.

    I have to give full access to program via:

    System Preferences -> Security & Privacy -> Privacy -> Full Disk Access -> Add Program.

    enter image description here