title: Extending SUDO timestamp in a BASH script
body: <p>There's a BASH script that might need more than 5 minutes to run a list of commands (majority are sudo)...What's the alternative? </p>
  
  <p>Some say...</p>
  
  <p>Use <code>sudo -v</code> </p>
  
  <p>seems like a good option, although, after reading Apple's <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/sudo.8.html" rel="nofollow">sudo(8) Man Page</a>, it was said...</p>
  
  <blockquote>
    <p>If given the -v (validate) option, sudo will update the user's time stamp, prompting for
                       the user's password if necessary.  This extends the sudo timeout for another 5 minutes
                       (or whatever the timeout is set to in sudoers) but does not run a command.</p>
  </blockquote>
  
  <p>I'm concerned with <em>prompting for the user's password if necessary</em>. What do they mean "if necessary"? </p>
  
  <p>If I have sudo -v in a bash script that, let's say, executes roughly 4 minutes since the last time sudo was used (1 minute left on timestamp). Thus, giving us another 5 minutes to the timestamp - Right?  </p>
  
  <p>As for the other option, someone mentioned to use a loop command for updating a timestamp.</p>
  
  <pre><code>while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2&gt;/dev/null &amp;
  </code></pre>
  
  <p>Can the above code work?</p>