0

How does one provide a password only once when running multiple long-running sudo commands in a bash for loop? For example I have a command like this:

for DATE in 20120902 20120903 20120904 20120905; do; sudo -u ...; sudo -u ...; sudo -u ...; done;
syker
  • 10,912
  • 16
  • 56
  • 68

1 Answers1

0

So, if you have multiple sudo commands, like below

for DATE in 20120902 20120903 20120904 20120905; do
    sudo echo $DATE;
    sudo echo $DATE;
    sudo echo $DATE;
  done;

it should only prompt you for the root password once. sudo starts a session where it leaves you machine exposed for like a minute or something (probably configurable somewhere). If you machine isn't behaving like this, then maybe you can configure it to do so.

Bradley Bossard
  • 2,439
  • 2
  • 23
  • 30