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
416 stars 248 forks source link

Auto Stop Idle Policy hangs on Amazon Linux 2 Instance (notebook-al2-v1) #82

Closed MarcusRosen-Rio closed 2 years ago

MarcusRosen-Rio commented 2 years ago

Hi,

The auto Stop Idle Lifecycle Configuration hangs when using Amazon Linux V2 (notebook-al2-v1) platform identifier type for Notebook, the same policy works without fail on V1. Suspect this is related to python2 Python3 upgrade.

https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/tree/master/scripts/auto-stop-idle

gzali4295 commented 2 years ago

try the following updated command instead of this [1]. Worked for me for both notebook versions.

(crontab -l 2>/dev/null; echo "/5 * /usr/bin/python3 $PWD/autostop.py --time $IDLE_TIME --ignore-connections") | crontab -

[1] https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/a6b627c7de883674b3cbeefdff34947ee08aadcd/scripts/auto-stop-idle/on-start.sh#L24