MacOS – Getting unknown command error when trying to run script via cron

bashcronmacos

I recently had to re-install 10.9.5 (default install) and am now finding that bash scripts that run perfectly from the command line (~/Me…) no longer work using crontab. I use crontab to invoke "Diskutil unmount volumeX" but am getting mail from cron saying "diskutil" command not found. Is it a PATH issue and if so how would I fix it.
Thank you in advance for any help.

Best Answer

cron uses /usr/bin:/bin as the default PATH and diskutil is in /usr/sbin.

Specify the full path to diskutil or add a line like PATH=/usr/bin:/bin:/usr/sbin:/sbin to the start of your crontab.

Enter which diskutil to find its path, or enter echo $PATH to find the path where your commands are working.