aws-samples / amazon-sagemaker-notebook-instance-lifecycle-config-samples

A collection of sample scripts to customize Amazon SageMaker Notebook Instances using Lifecycle Configurations
MIT No Attribution
422 stars 250 forks source link

restart jupyter-server : command not found #76

Closed jackkwok closed 8 months ago

jackkwok commented 2 years ago

The on-start.sh script attempts to restart the jupyter server but I got error that the restart command is not found. How to fix that?

2021-12-22T15:06:26.697-08:00 | Restarting the Jupyter server.. 2021-12-22T15:06:32.236-08:00Copy/tmp/OnStart_2021-12-22-23-068l8lm3x9: line 24: restart: command not found | /tmp/OnStart_2021-12-22-23-068l8lm3x9: line 24: restart: command not found

Source of the restart command: https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/master/scripts/persistent-conda-ebs/on-start.sh

anand-kummari commented 2 years ago

Hey, I am also facing this issue. Does anyone have a solution for this ?

I see that when using notebook-al1-v1 platform identifier, the notebook starts just fine. But when I use notebook-al1-v1 platform this error occurs. notebook-al1-v1 is based on Amazon Linux-1 and notebook-al2-v1 is based on Amazon Linux 2. However, AL1 (Amazon Linux 1) does not support security patches and updates from 18-04-2022.

Considering this, how to solve restart: command not found error on Sagemaker Notebook Instance based on AL2

welch-connor commented 2 years ago

Faced a similar issue; was able to resolve using a script from a separate AWS GitHub: https://github.com/aws-samples/amazon-sagemaker-notebook-instance-customization#51-restart-jupyterlab

# For notebook instance with alinux (notebook-al1-v1)
initctl restart jupyter-server --no-wait

# Use this instead, for notebook instance with alinux2 (notebook-al2-v1)
systemctl restart jupyter-server

You won't need to use 'sudo' since Lifecycle Config executes all commands as root by default

AmintorDusko commented 2 years ago

Thank you, @welch-connor! This was very helpful!

dannyfraser commented 1 year ago

Faced a similar issue; was able to resolve using a script from a separate AWS GitHub: https://github.com/aws-samples/amazon-sagemaker-notebook-instance-customization#51-restart-jupyterlab

# For notebook instance with alinux (notebook-al1-v1)
initctl restart jupyter-server --no-wait

# Use this instead, for notebook instance with alinux2 (notebook-al2-v1)
systemctl restart jupyter-server

You won't need to use 'sudo' since Lifecycle Config executes all commands as root by default

I found that initctl didn't work either - I get a "Rejected send message" response.

NiccoloSalvini commented 1 year ago

This is also related to Metaflow CloudFormation stack template which uses initctl restart jupyter-server --no-wait producing a the notebook instance fail. I updated the temp at line 1130 with systemctl restart jupyter-server and now works fine.

dmlause commented 8 months ago

Closing this issue, please reopen if there is still an issue that requires a separate fix, thank you.