Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.5: Run a Time Machine backup then shut down' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Run a Time Machine backup then shut down
Authored by: wallybear on Jun 27, '08 09:08:50AM
Your script can be trimmed a lot:

property querylist : {"backupd"}
property app_is_up : missing value --this line is superfluous

set app_is_up to false

do shell script
"/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper > /dev/null 2>&1  &"

repeat
	delay 10
	repeat with i in querylist
		if IsProcRunning(i) then set app_is_up to true
	end repeat
	if app_is_up then
		set app_is_up to false
	else
		ignoring application responses
			tell application "loginwindow" to «event aevtshut»
		end ignoring
		exit repeat
	end if
end repeat

on IsProcRunning(theProc)
	try
		do shell script "ps auxc | grep \"" & theProc & "\""
		return true
	on error
		return false
	end try
end IsProcRunning


and, as you look only for the "backupd" process, can be trimmed down to this:


do shell script
"/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper > /dev/null 2>&1  &"

repeat
	delay 10
	if not IsProcRunning("backupd") then
		ignoring application responses
			tell application "loginwindow" to «event aevtshut»
		end ignoring
		exit repeat
	end if
end repeat

on IsProcRunning(theProc)
	try
		do shell script "ps auxc | grep \"" & theProc & "\""
		return true
	on error
		return false
	end try
end IsProcRunning


Moreover, it would be better making it a logout script

[ # ]