Jump to content

Give an example use of the nohup command

Mrcrysis2000
Go to solution Solved by Ciccioo,

the nohup command is used to detach a command from the terminal's lifespan

when you launch a program from a terminal, the program is bonded to the terminal. this means that if you close the terminal, the program closes too.

nohup avoids this behaviour, allowing you to launch a program and then close the terminal

 

for example, if you want to run a program as a daemon in the background you could do it like this

nohup ./program &

where the ampersand is used to put the program in the background

 

so like if a script throws a error you can use it to log the error.

 

so like hohup script.pl

i guess that he's referring to the fact that the output of the program gets redirected to a file called "nohup.out" in the current directory

that's just a side effect, if you want to redirect the output you can just redirect stdout using the ">" operator

Hi 

 

I understand what nohup command is about but im struggling to find out when it could be used? or a useful example when the parent process it terminated 

 

Any help?

Link to comment
Share on other sites

Link to post
Share on other sites

so like if a script throws a error you can use it to log the error.

 

so like hohup script.pl

PEWDIEPIE DONT CROSS THAT BRIDGE

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

the nohup command is used to detach a command from the terminal's lifespan

when you launch a program from a terminal, the program is bonded to the terminal. this means that if you close the terminal, the program closes too.

nohup avoids this behaviour, allowing you to launch a program and then close the terminal

 

for example, if you want to run a program as a daemon in the background you could do it like this

nohup ./program &

where the ampersand is used to put the program in the background

 

so like if a script throws a error you can use it to log the error.

 

so like hohup script.pl

i guess that he's referring to the fact that the output of the program gets redirected to a file called "nohup.out" in the current directory

that's just a side effect, if you want to redirect the output you can just redirect stdout using the ">" operator

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×