I want the cronjob to do some things as the superuser, and depending on the result, launch an app as me, the logged-in user.
I've tried a bunch of things but nothing I think should work does.
Similar questions:
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityI want the cronjob to do some things as the superuser, and depending on the result, launch an app as me, the logged-in user.
I've tried a bunch of things but nothing I think should work does.
Similar questions:
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