Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Add terminal #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

toddwilkerson
Copy link

Issue #, if available:

Description of changes: Added code to query for activity in terminals, prevent shutdown if terminal is not idle.

Testing Done

  • Notebook Instance created successfully with the Lifecycle Configuration
  • Notebook Instance stopped and started successfully
  • [NA] Documentation in the script around any network access requirements
  • [NA] Documentation in the script around any IAM permission requirements
  • CLI commands used to validate functionality on the instance
  • [NA] New script link and description added to README.md
  • Two terminals open.

  • root crontab entry, run every minute for testing, look for idleness of 60 seconds.

*/1 * * * * /home/ec2-user/anaconda3/bin/python3 /tmp/autostop.py --time 60 --ignore-connections>> /var/log/jupyter.log
  • Type random commands in terminals, then wait a few minutes.

  • /var/log/jupyter.log contents:

Notebook is idle. Last activity time =  2023-04-07 15:27:02.004000
Terminal 1 is not idle. Last activity time =  2023-04-07 15:34:06.549102
Terminal 2 is not idle. Last activity time =  2023-04-07 15:35:01.070414
Notebook not idle. Pass.
Notebook is idle. Last activity time =  2023-04-07 15:27:02.004000
Terminal 1 is not idle. Last activity time =  2023-04-07 15:35:03.711165
Terminal 2 is idle. Last activity time =  2023-04-07 15:35:01.070414
Notebook not idle. Pass.
Notebook is idle. Last activity time =  2023-04-07 15:27:02.004000
Terminal 1 is not idle. Last activity time =  2023-04-07 15:36:03.047135
Terminal 2 is idle. Last activity time =  2023-04-07 15:35:01.070414
Notebook not idle. Pass.
Notebook is idle. Last activity time =  2023-04-07 15:27:02.004000
Terminal 1 is idle. Last activity time =  2023-04-07 15:37:02.624094
Terminal 2 is idle. Last activity time =  2023-04-07 15:35:01.070414
Closing idle notebook

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant