After you installed JupyterLab on your Ubuntu Analytics server, you’ll realize that it becomes quite annoying after the first 10 times to start JupyterLab through ssh. It’s much easier to have it run when you start your server.
There are a couple of files you’ll have to create and run some commands to get this to work.
- Create an executable bash script. Lets name it jupyterlab.sh and place it in your home directory.
cd /home/username/ sudo nano juperterlab.sh
- Type in the same command that you use to start JupyterLab. Replace the <installpath> with the absolute path to your installation. For example no using ~ for home directory. Use /home/username for the absolute path.
#!/bin/sh /<installpath>/anaconda3/bin/jupyter lab --ip=192.168.1.2 --port=12345 --no-browser
- Make the file executable by typing the following
sudo chmod +x jupyterlab.sh
- Create a service file ending in .service. I use the nano editor but you can use any editor.
sudo nano /etc/sytemd/system/jupyterlab.service
- And type in the following details into the file
[Unit] Description=Jupyterlab After=syslog.target network.target [Service] User=username ExecStart=/bin/bash /home/username/jupyterlab.sh [Install] WantedBy=multi-user.target
- Save the file and then run the following command to enable the service to autostart.
sudo systemctl enable jupyterlab.service
- Start the service
sudo service jupyterlab start
- Navigate to the URL http://192.168.1.2:12345 and check if you can log in.
- If this works then reboot the server and try the step above again.
sudo reboot
- If it works, Great ! If it doesn’t then try this command to see any issues.
sudo service jupyterlab status