Skip to content

Instantly share code, notes, and snippets.

@xaratustrah
Last active August 27, 2018 12:01
Show Gist options
  • Save xaratustrah/e481235d3c8a72505682e0b924acccbb to your computer and use it in GitHub Desktop.
Save xaratustrah/e481235d3c8a72505682e0b924acccbb to your computer and use it in GitHub Desktop.
jupyter_service_osx.md

Running Jupyter at boot in OSX using launchctl

Create a plist file in your user directory. In the following change USERNAME to your own.

/Users/USERNAME/Library/LaunchAgents/local.jupyter.notebook.plist

With this content:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>local.jupyter.notebook</string>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/jupyter</string>
      <string>notebook</string>
      <string>--ip=0.0.0.0</string>
      <string>--port=8888</string>
      <string>--no-browser</string>
      <string>--notebook-dir=/Users/USERNAME/</string>
      <string>--config=/Users/USERNAME/.jupyter/jupyter_notebook_config.py</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/Users/USERNAME/.jupyter/jupyter.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/USERNAME/.jupyter/jupyter.log</string>
  </dict>
</plist>

now go to that directory and load / start the daemon:

launchctl load local.jupyter.notebook.plist
launchctl start local.jupyter.notebook.plist

The notebook will be running now and also after boot. you can also stop or unload the service:

launchctl stop local.jupyter.notebook.plist
launchctl unload local.jupyter.notebook.plist

if you remove plist file and the daemon ist still running, you can remove it by:

launchctl remove local.jupyter.notebook.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment