OK I have set up jupyter notebook on a gcp VM, I want it to start automatically every time VM is started with a predefined token. (OS in Centos)
Does any one have any idea how to solve this final issue so that we can get the jupyter notebook started under the user test1 , everytime the VM starts ?
Here is what I have done so far
- Created a local test1 user and created a Virtual env for it, installed jupyter notebook inside the virtual env for isolation of python
pyton3 -m venv tvenv
source tvenv\bin\activate
pip install jupyter
- Understood that I would need to generate config and update token / ip / port etc inside the config becuase dynamically generated token cannot be used
jupyter notebook --generate-config
- modified NotebookApp.token/NotebookApp.port/NotebookApp.ip etc attributes to get that to work.
- based on an existing question created a shell script to be added to the start up to the gcp VM
sudo -u test1 bash -c 'cd ~/; nohup tvenv/bin/jupyter-notebook &'
When i run the command manually from root it works when I update in GCP startup it constantly fails saying
Account or password is expired, reset your password and try again
Note : Helpful debugging tip. You can get the startup script logs by running below command once inside the VM
sudo journalctl -u google-startup-scripts.service