How can root launch a regular Mac application from a cron job in /etc/crontab?
I figured out the key was to use su
with -l
, -c
and single quotes:
su -l myloginname -c '/usr/bin/open -a [App].app'
In context:
*/15 * * * * root if { ! /usr/bin/diff /var/tmp/foo /var/backups/bar >> /var/log/foobar-diff.log ; } ; \
then /usr/bin/su -l myloginname -c '/usr/bin/open -a /Applications/iProcrastinate.app > /dev/null 2> /dev/null' ; \
/bin/date >> /var/log/foobar-diff.log ; fi