Last active
August 26, 2020 19:21
-
-
Save bhavsarpratik/0c2f0ccbf193b1da2d0fd0a17e8681ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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