Skip to content

Instantly share code, notes, and snippets.

@bhavsarpratik
Last active August 26, 2020 19:21
Show Gist options
  • Save bhavsarpratik/0c2f0ccbf193b1da2d0fd0a17e8681ce to your computer and use it in GitHub Desktop.
Save bhavsarpratik/0c2f0ccbf193b1da2d0fd0a17e8681ce to your computer and use it in GitHub Desktop.
import os
def run_command(cmd):
return os.system(cmd)
def shutdown(seconds=0, os='linux'):
"""Shutdown system after seconds given. Useful for shutting EC2 to save costs."""
if os == 'linux':
run_command('sudo shutdown -h -t sec %s' % seconds)
elif os == 'windows':
run_command('shutdown -s -t %s' % seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment