Applescript Ignoring Timeout
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi Guys,
Long time listener, first time caller. I have cobbled this script together from other posts. It is designed to close all open applications with exceptions and rsync a directory to a removable drive. Unfortunately the script times out after some hours when rsyncing some large files (>~40 gig).
Script Below
--------------------------------------------------------------------------------
set userCancelled to false
with timeout of 86400 seconds -- one day
display dialog "Do you want to Sync and Shutdown? " & "" buttons {"No", "Yes"} with icon caution with title "Backup" default button "Yes"
if button returned of result = "Yes" then
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder", "AppleScript Editor", "Mail", "Address Book", "iCal", "Things", "Skype"}
try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
if this_process is not in white_list then
tell application this_process
quit
end tell
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try
set {weekday:d} to (current date)
set date_format to d as string
display dialog date_format & "Syncing starts in 5 seconds…
This operation may takes few minutes." with icon note buttons {"OK"} with title "Backup" giving up after 5
do shell script "rsync -avE –delete-after ~/Library/VirtualBox/ /Volumes/Daily_Backup/Backup/VirtualBox/" & date_format & "/ > ~/rsync.log || echo -n"
-- do shell script "rsync -avE –delete-after ~/Documents/ /Volumes/Daily_Backup/Backup/Documents/" & date_format & "/ > ~/rsync.log || echo -n"
--display dialog "Backup completed Do you want to see the log?" with icon note buttons {"No", "Yes"} with title "Backup" default button "Yes" giving up after 10
--if button returned of result = "Yes" then
-- tell application "Finder" to open file "rsync.log" of home
--end if
try
set answer to display dialog "Backup complete. Shutting down in 30 seconds." giving up after 30
on error number -128
set userCancelled to true
end try
if userCancelled then
else if gave up of answer then
tell application "Finder"
shut down
end tell
end if
end if
end timeout
--------------------------------------------------------------------------------
Script Above
It does take any longer than 24 hours and if there is nothing or little to rsync the script executes without an issue.
I have seen other posts but none of their suggestions seem to help.
Please HELP.... it is really frustrating me though I am sure I have done something stupid.
Thanks,
Will
3 replies
Sign in or join Beachball Help to reply.
- 0
- 0
- 0