- Copy the jupyter.servicefile to /etc/systemd/system/jupyter.service
- Edit that file to change the home directory
- Setup a password on jupyter by running jupyter notebook password
- Run systemctl daemon-reloadto notify systemd about the new service
- Run systemctl enable jupyter.serviceto enable it, so it will start every time
- Run systemctl start jupyter.serviceto start it the first time. After that, because of theWantedBy=graphical.targetthe service will be run on login
          Last active
          June 3, 2023 13:22 
        
      - 
      
- 
        Save wjladams/2ff01829df039fe03e271b061dac4166 to your computer and use it in GitHub Desktop. 
    Running Jupyter as service on ubuntu with systemd
  
        On SELinux systems (including fedora) you need to allow the system to execute things in the anaconda directory. To do this you need to run (replacing /home/wjadams with your home directory)
sudo semanage fcontext -a -t bin_t '/home/wjadams/anaconda3/bin.*'
sudo chcon -Rv -u system_u -t bin_t '/home/wjadams/anaconda3/bin'
sudo restorecon -R -v '/home/wjadams/anaconda3/bin'And then the system should allow you to run jupyter-notebook from that directory
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [Unit] | |
| Description=Jupyter Server Setup | |
| After=syslog.target network.target | |
| # Comment out the following on Fedora/RedHat/Centos, for some reason | |
| # it doesn't have the syslog.socket, but removing the "Requires" doesn't effect anything | |
| Requires=syslog.socket | |
| [Service] | |
| User=wjadams | |
| Type=simple | |
| WorkingDirectory=/home/wjadams | |
| ExecStart=/home/wjadams/anaconda3/bin/jupyter-notebook --no-browser --NotebookApp.token= | |
| [Install] | |
| WantedBy=graphical.target | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment