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

Open a secondary application instance via Terminal Apps
When you need to open a second instance of an application, you can user the sudo command. This is handy if you need to ensure that anything in the current instance is retained if the application crashes. For instance, for Safari I'd run the command...
sudo -u peter /Applications/Safari.app/Contents/MacOS/Safari &
The -u switch specifies which user to run the process under (you'd use the logged-in user's username). The ampersand at the end prevents gibberish from being displayed in the console window while the application is running. If you run the above, then open Activity Monitor (or use top), you'll see Safari running under two processes (as well as have two Safari icons in the dock).

[robg adds: This seems to work, though I'm not sure how things like preference files are handled when multiple copies of the app are in use.]
    •    
  • Currently 3.60 / 5
  You rated: 4 / 5 (5 votes cast)
 
[11,965 views]  

Open a secondary application instance via Terminal | 9 comments | Create New Account
Click here to return to the 'Open a secondary application instance via Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open a secondary application instance via Terminal
Authored by: fds on May 22, '07 08:14:31AM

If you use the currently logged-in user's username with sudo, then of course the whole sudo part is pointless, just start it directly, eg.
/Applications/Safari.app/Contents/MacOS/Safari &



[ Reply to This | # ]
Open a secondary application instance via Terminal
Authored by: lukec on May 22, '07 08:15:28AM
You can also execute the command without the sudo. You just need to find the executable under the MacOS folder in any application's package contents.

eg.
/Applications/Safari.app/Contents/MacOS/Safari &

Quicksilver fans are already aware that if an app is already running you can choose 'launch a copy' in order to... launch a copy of the app.

Luke

[ Reply to This | # ]
Open a secondary application instance via Terminal
Authored by: boredzo on May 22, '07 09:00:54AM

Nicholas Riley's awesome utility launch can do the same thing:

launch -m -a Safari

[ Reply to This | # ]

Open a secondary application instance via Terminal
Authored by: mark hunte on May 22, '07 10:42:38AM

So does anyone know what happens to prefs if two instances of the same app are running?

Cheers

M

---
mh



[ Reply to This | # ]
Open a secondary application instance via Terminal
Authored by: club60.org on May 22, '07 12:29:14PM

If you launch Safari under another user everything should go just fine as Safari will use that user's preferences.



[ Reply to This | # ]
Open a secondary application instance via Terminal
Authored by: pamon on May 22, '07 02:15:39PM

It's nice hint. It becomes quite handy when you're using an instant messengers; perhaps to trick your friends and/or enemies. It's a pitty though that you can't use it with iTunes. I wonder why?



[ Reply to This | # ]
Duplicate hint
Authored by: elmimmo on May 22, '07 05:46:31PM
Not to be an ass, but the hint is a duplicate of Launch multiple instances of any given application, only that less detailed (and hence works on less apps).

Sudo is not even needed unless you want to run the app as ANOTHER user (in which case, it does not work with non-admin users, who would have to rely on the login command instead)

[ Reply to This | # ]

'pseudo' is a 'secondary' app launcher with a gui for sudo
Authored by: zahadum on May 23, '07 10:19:24AM
http://personalpages.tds.net/~brian_hill

CLI can be an akward way to /manage/ launching apps ...

'pseudo' is a gui for running apps as root - it sits up in the systemenubar and has a dop down list of favorites/recent apps that have been launched as root.

this is a tremendously useful when apps hang in osx (which is a daily, in fact often it is a constant, occurance!! - grrrr) ... one doesnt have to go through the long painful process of logging in to another user profile (which can take 1-5 minutes! when the recalcitrant app starts to cascade through to the rest of the system) just in order to continue working with an app that is hanging!

btw: the info contained in this hint - the CLI version - tells a useful aspect NOT covered in pseudo - namely the ability to launch an app with any user's ACL permissions! ... i hope that brian hill adds this feature to pseudo! ...

MINI RANT: it's too bad that cocoa doesnt have an effective component model or a 'core plugin' API so that it was easier for third parties to extend an app! ... since most osx apps do not come with applescript, cocoa apps end up - IN PRACTICE - as having as brittle an object model as COM (activex) is for windoze! .... ah for the good old days when OpenDoc used IBM's SOM in order to support new methods at runtime without a recompile or more importantly without the need to expose source code (ie intellectual property) in order for third parties to make changes to an object!

---
mailto:osxinfo _at_ yahoo.ca


[ Reply to This | # ]

Open a secondary application instance via Terminal
Authored by: mauldus on Aug 17, '08 06:18:43PM

I've always just option+drag copied an app and double-clicked to launch it. But the sudo option leads me to think it would be possible to trick the app into using another user's preferences to simulate independent instances. Worth a shot.



[ Reply to This | # ]