Repeated Authentication on long script

Hello,

I did a quick search of the site, but couldn’t find anything related. I’ve written an AppleScript that takes a long time to run and needs to write to a file ‘with administrator privileges’. Unfortunatley for me, it keeps authenticating every couple of minutes, has anyone got a workaround for this? I’d ideally like to run the script, authenticate and come back later.

I am running this in the Script Editor, but I think it would act the same way compiled.

Thanks in advance for any advice.

sudo defaults to a five-minute timeout (unless you do shell script “sudo -k”). To change that behavior you have to use the sudoer timestamp_timeout function to set the timeout to what you want it to be. Remember to set it back. See: man:sudoer for the details.