Skip to content

Instantly share code, notes, and snippets.

@hashlash
Created April 11, 2020 09:41
Show Gist options
  • Save hashlash/e6620513b541a3a8c441272c39918bfe to your computer and use it in GitHub Desktop.
Save hashlash/e6620513b541a3a8c441272c39918bfe to your computer and use it in GitHub Desktop.
Run command with unlimited sudo session time
#!/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