Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Created June 17, 2020 20:24
Show Gist options
  • Select an option

  • Save gmolveau/45ee52f3ec629480c307173dcb75d879 to your computer and use it in GitHub Desktop.

Select an option

Save gmolveau/45ee52f3ec629480c307173dcb75d879 to your computer and use it in GitHub Desktop.
Bash/shell script command keep-alive sudo until the command has finished
# Ask for the sudo password
sudo -v
# Keep-alive: update existing `sudo` time stamp until the command has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment