Starting command line program/script in background as job (Linux, Mac)

It is important to  use the command “nohup” and also redirect everything, otherwise the job will be killed after leaving console

nohup ./your_program_or_script_here > copyout.log 2> copyout.err < /dev/null &

On the other side, if you need just to run something in background because you are afraid that you will loose the session, the best way for it is using tmux, it can be installed with “apt-get install tmux” in Ubuntu Linux or “brew install tmux” on Mac

Open new session:

tmux new -s session_name

Attach to the lost session:

tmux attach -t session_name

, , , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: