I'm trying to learn how to use cron for repetative tasks. I have an external disk that needs to be unmounted and remounted every hour due to some problems that a backup utility (specifically, TimeMachine) is having repeatedly accessing the device. I've created a shell script that will find the mount point of the drive, unmount it, and then remount it. Here's the code:
#!/bin/sh
# Finds the device node of the drive 'Rebel Base', and saves it to variable i
export i=`diskutil info 'Rebel Base' | grep 'Device Node' | cut -d : -f 2 | sed 's/^ *//g' | sed 's/ *$//g';`
# unmounts device found at variable i
hdiutil unmount -force $i
sleep 1
# remounts device found at variable i
hdiutil mountvol $i
When I run this as a shell script, it works just fine. However, cron returns the following error:
line 4: diskutil: command not found
hdiutil: unmount: no file specified
Usage: hdiutil unmount [options] <mountpoint>
hdiutil unmount -help
hdiutil: mountvol: no device specified
Usage: hdiutil mountvol [options] <devname>
hdiutil mountvol -help
My cron looks like this:
* 9-16 * * 1-5 sh /Users/danielmarcus/Dropbox/programming/relaunchRebel.sh
What am I doing wrong here? Any and all help is very much appreciated.