how to automate / run 'brew cask upgrade' as a cron job? I wish to run brew cask upgrade in a cronjob, but it prompts for a password.

When I run the job as root all permissions are screwed up.

Howto run that command in a cronjob env? I use zsh.

~ brew cask upgrade
==&gt; Casks with `auto_updates` or `version :latest` will not be upgraded
==&gt; Upgrading 2 outdated packages:
java 13.0.1,9:cec27d702aa74d5a8630c65ae61e4305 -&gt; 13.0.2,8:d4173c853231432d94f001e99d882ca7, keepassxc 2.5.2 -&gt; 2.5.3
==&gt; Upgrading java
==&gt; Downloading https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_osx-x64_bin.tar.gz
######################################################################## 100.0%
==&gt; Verifying SHA-256 checksum for Cask 'java'.
==&gt; Backing Generic Artifact 'openjdk-13.0.1.jdk' up to '/usr/local/Caskroom/java/13.0.1,9:cec27d702aa74d5a8630c65ae61e4305/jdk-13.0.1.jdk'.
Password:
I have tried using cron as well but it just won't go as well. Instead I wrote a script called macupdate that held the instructions for homebrew to upgrade all installed apps as well as for the mac to look for and download any MacOS updates, made it executable and selected it as a startup application.

brew update &amp;&amp; brew upgrade &amp;&amp; brew cask upgrade --greedy; mas upgrade;
sudo softwareupdate -i -a --restart