Run a oneshot job at next boot/login time on OSX
launchd-oneshot can be installed via Homebrew
brew install cybertk/formulae/launchd-oneshotTo add a oneshot job script.sh to run at next boot time
sudo launchd-oneshot script.shTo add a oneshot job script.sh to run at next user login time
sudo launchd-oneshot script.sh --on-loginTo add a oneshot job script.sh to run at next user login time with root, and launchd-oneshot will pass current login user as $1 to script.sh
sudo launchd-oneshot script.sh --on-login-as-rootlogs is written to /tmp/launchd-oneshot.log, you can view it with
tail -f /tmp/launchd-oneshot.loglaunchd-oneshot installs a launchd agent under /Library/LaunchDaemons for each job. When agent is running, it will start launchd-oneshot in RUN mode, which will execute the origin job and remove the launchd agent when job is completed.
For --on-login job, in order to run the job as root, launchd-oneshot will install a trigger launchd agent under /Library/LaunchAgents in addition. When user login, the trigger agent will start running. And it will trigger the launchd agent under /Library/LaunchDaemons to run through launchd's KeepAlive:OtherJobEnabled mechanism.