Created
April 11, 2020 09:41
-
-
Save hashlash/e6620513b541a3a8c441272c39918bfe to your computer and use it in GitHub Desktop.
Run command with unlimited sudo session time
This file contains hidden or 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/sh | |
(while true; do sudo -v; sleep 60; done)& | |
job_pid=$! | |
echo $job_pid | |
cleanup(){ | |
kill $job_pid | |
} | |
trap cleanup EXIT | |
trap cleanup INT | |
sudo /path/to/command arg1 arg2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment