Rsync fails due to Sudo timeout
How are you actually invoking the script? If you run a script like sudo script.sh, all commands inside the script are run as superuser and you should never have it time out. If you're running a script that has sudo commands inside it, then it could ask for a password more than once if it takes too long between sudo commands. The sudo timeout only applies to new invocations of the sudo command. If your case is the latter, you do have the option of using the command sudo -v in your script which will extend the timeout by its default value (normally 5 minutes, but see below for how to change it), but if everything inside needs superuser permissions anyways, it makes more sense to invoke the entire script with sudo.

If you do want to change the sudo time out, you need to edit the sudoers file:


Bring up the sudoers file:

sudo visudo

Find the line that starts with:

Defaults    env_reset

Add a comma and the command timestamp_timeout=minutes to the end
(replace minutes with the number of minutes desired, 0 will always
ask for a password, a negative number will never time out -
dangerous):

Defaults    env_reset,timestamp_timeout=10

Save and close the file.