Kill All appname script completes but exit code 1

atomczynski
Valued Contributor

I'm working on a script which will update the (Google) Backup and Sync App to the current version.

I have few scripts as part of the policy:
"Quit Backup and Sync" - priority Before
"Install Google Backup and Sync" - priority After
"Open Backup and Sync" - priority After

The quit app script is as follows:
#!/bin/bash
killall Backup and Sync

When I look at the policy log I see the following:
Script exit code: 1
Script result: No matching processes were found<br/>
Error running script: return code was 1.

I suspect the app quits as part of the install script.

7 REPLIES 7

mickgrant
Contributor III

give this command a try, I have tested it and i will definitely shutdown backup and sync

#!/bin/sh
for pid in `ps -ef | grep 'Backup and Sync.app' | awk '{print $2}'` ; do kill $pid ; done

tlarkin
Honored Contributor

Does it have helpers or user agents? If so, you might want to look at quitting it a different way since PID can be unreliable or have weird results.

mickgrant
Contributor III

@tlarkin the script above pulls the PID of anything related to backup and sync and kills them all

atomczynski
Valued Contributor

@mickgrant I've used your script, when I run it as part of the workflow I see
Script exit code: 1
No such process<br/>
Error running script: return code was 1.

mickgrant
Contributor III

@atomczynski its probably because jamf is running the command as root, and not seeing the process running as the user.

tlarkin
Honored Contributor

@mickgrant I see it iterates through a data set of PIDs, the problem with that is, what happens when you kill the wrong thing. If an app has helpers that register as another process, you could potentially also kill them

atomczynski
Valued Contributor

I was able to quit the app by doing this:

#!/bin/bash
osascript -e 'tell application "Backup and Sync" to quit'

So far I've tested it on one machine only.