Skip to content

Instantly share code, notes, and snippets.

@ftiff
Last active February 10, 2017 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftiff/8f4d82ed11f4363fa6589d435b6f3645 to your computer and use it in GitHub Desktop.
Save ftiff/8f4d82ed11f4363fa6589d435b6f3645 to your computer and use it in GitHub Desktop.
mycliapp-launchdaemon.sh
#!/bin/bash
plist=/Library/LaunchDaemons/io.fti.mycliapp.plist
# Scenario 1 -- app:killed instantaneously -- plist:removed -- launchdaemon:removed
/Applications/MyCliApp.app/Contents/MacOS/MyCliApp &
rm $plist
launchctl remove io.fti.mycliapp
# Scenario 2 -- app:launched -- plist:may not be removed (eg. reboot) -- launchdaemon:same
/Applications/MyCliApp.app/Contents/MacOS/MyCliApp
rm $plist
launchctl remove io.fti.mycliapp
# Scenario 3 -- app:not_launch (see error below) -- plist:removed -- launchdaemon:removed
# Error -> "nohup: can't detach from console: Inappropriate ioctl for device"
nohup /Applications/MyCliApp.app/Contents/MacOS/MyCliApp &
rm $plist
launchctl remove io.fti.mycliapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment