Lesser known linux commands : nohup

nohup is a command which helps us to run any command immune to hang ups.  Assume that we run a command and it takes a long time to finish. If you log out while it is running the process will be terminated. If we want a command to run even if we log out then nohup can be used.

We can use nohup like this

nohup mylongrunningprogram  >logfile &

or

nohup mylongrunningprogram &

Explanation:

nohup : the command
mylongrunningprogram: the command we want to run

> logfile : redirect standard out messages to a file named logfile.

If not specified output will be stored in  nohup.out (as used in the second example above)

& : run the process in the background

 

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: