Apple hasn't killed
cron (yet), and so I think you have at least two options:
cron is "old-school" command-line Unix. It uses a
crontab to define the schedule. It is free, open-source and widely used. It is easy to use - if you understand its limitations.
launchctl have more capability than
cron, but from your question, it appears these added capabilities are not necessary. But if you're still interested, there are some things you should know. The first thing you should know is
LaunchControl; you used the word easy in your question, and this all but eliminates
LaunchControl is a 3rd-party commercial (not free) app that provides a sane GUI scheduling mechanism for
launchd; it is what
launchctl should have been.
The first step will depend on whether or not
root (Administrator) privileges are required. Since you didn't mention that they were, we'll proceed under the assumption that user privileges are all that is required by your
- From the
Terminal app on your iMac:
% crontab -e
You may receive a prompt asking you to select a default editor for your
crontab. If you're not sure which to select, choose
nano as your editor.
crontab will open in your chosen editor.
Add the following line to the bottom of your
@reboot /bin/sleep 10; /var/tmp/test.sh >> /Users/<YOURUSERID>/test_sh_log.txt 2>&1
Breaking this down:
cron to run the following command(s) when the system boots
/bin/sleep 10 tells
cron to sleep for 10 seconds before running the next command. This may not be necessary, but if you use network services or mount file systems, the
sleep time will give the system time to get those running before your script calls on them.
/var/tmp/test.sh is your script, w/ execute permissions properly set.
>> /Users/<YOURUSERID>/test_sh_log.txt 2>&1 redirects any output to a convenient log file;
2>&1 gets both
stderr (error messages). This is often helpful for troubleshooting, or if you wish your shell script to output anything while running.
reboot your iMac, test.sh should begin running.
Apple's "security measures" seem to be in constant flux, and there may be additional steps required to make Apple happy. The need for these steps depends upon too many factors to cover here. If you encounter difficulties, post comments here & we'll respond.