Created
February 24, 2016 23:59
-
-
Save mattbell87/eac373d9f26a22e01605 to your computer and use it in GitHub Desktop.
Keep sudo alive until a bash script has finished.
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
#!/bin/bash | |
# Ask for password | |
sudo -v | |
# Or give the password if you know it | |
# echo 'PASSWORD' | sudo -vS | |
while true; do sudo -n true; sleep 60; kill -0 \"$$\" || exit; done 2>/dev/null & | |
# do stuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment