Script to quit terminal after a restart...or better alternative?

discounteggroll
New Contributor III

Is there a way to get terminal to quit after a restart, if it was open prior? We perform OS updates via cache and execute policies remotely. Once the OS update is complete and the computers restart our users see terminal still open, and sometimes get confused and/or scared about what to do with it.

This poses no security threat, but if possible I'd like to have terminal not open back up, (and also have whatever else was open previous to the restart come back as well)

2 REPLIES 2

thoule
Valued Contributor II

/Users/<username>/Library/Saved Application State contains an entry for each application. I guess you could loop through that directory on each users account and delete 'com.apple.Terminal.savedState' directory for each user.

JayDuff
Contributor II

You could have a script like this:

osascript -e 'quit app "terminal"'

Then apply it with a policy on Startup or login.