theJuice
theJuice

Reputation: 11

Closing Terminal without killing command

I'm starting with Terminal on Mac (OS 10.9.2), and I've got this command which will take a very long time to run. How can I launch this command and then quit the terminal while the command is being carried on i.e. without killing the command?

Just for info, my command finds a certain type of file in my computer then copy it to an external volume.

Thanks

Upvotes: 1

Views: 1609

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753455

Use nohup:

(nohup long-running-command arg1 arg2 … argN) & sleep 1

The sleep 1 gets the message about 'output to nohup.out' printed before the next prompt; it is otherwise unnecessary. This does assume you planned ahead — you knew you'd be running a long-running command. If you start it off and then find it is taking a long time, you have to look to suspend it (Control-Z) and then background it (bg %1) and disown it (that's a Bash built-in command — disown %1).

Upvotes: 1

Related Questions