Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samwan/63afec550d47a15110b048227976bd25 to your computer and use it in GitHub Desktop.
Save samwan/63afec550d47a15110b048227976bd25 to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Adapting this auto-shutdown tutorial to work with Gradient Notebooks, which don't provide ssh access: https://paperspace.zendesk.com/hc/en-us/articles/115002807447"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Update apt-get and install xprintidle. \n",
"# Pass \"-y\" argument to say Yes at the prompts, otherwise notebook will freeze.\n",
"!apt-get -y update\n",
"!apt-get -y install xprintidle"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Download shutdown script files and extract to root.\n",
"# Gradient notebooks run as root, so there's no need to sudo.\n",
"!curl https://s3.amazonaws.com/ps.public.resources/tools/idle_shutdown.tgz | tar -xzv -C /"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Update idle time\n",
"# !echo \"IDLE_TIME=1\" > /etc/default/idle_shutdown\n",
"!cat /etc/default/idle_shutdown"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# This doesn't work\n",
"!bash /usr/local/bin/idle_shutdown.sh"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# This doesn't work\n",
"import subprocess\n",
"subprocess.call(['/usr/local/bin/idle_shutdown.sh'], cwd=\"/\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# This doesn't work either \n",
"import os\n",
"import sys\n",
"os.system(\"bash /usr/local/bin/idle_shutdown.sh\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment