Lesser known Linux commands – nohup

nohup is a command which will help us to run a programme even after logging out and immune to hangup signals.

Generally if we log out all process started will be terminated. If we want to run some process, which doesnt require human interference, even after log out, we can use nohup.

Say I have a script mymonitor.sh to monitor memory usage and it takes one hour. I want run this script in the background and collect statistics. I can run it like this

$ nohup myscript.sh &
(assuming myscript.sh has it own logic for exiting – not an endless loop)

Now the script will run even if I log out. Normally the output will be dumped in nohup.out file.


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: