- ./start.sh
- nohup ./start.sh > start_1.log
So why use the nohup command when you can directly run the shell script without it. The basic difference between the two is that when you run a shell script with nohup, even after logging out from the terminal it runs in the background. This is not the case with direct execution, where when you close the terminal the process is also aborted.
For an example, if we startNodeManager.sh file with direct execute command, you will be able to see the log of how it is starting up. The nodemanager will eventually startup. The problem with this is that when you close the terminal, the nodemanager will go down. Inorder to avoid this what you can do is to run the shell script with nohup command.
With nohup command the linux process is not aborted when the terminal is closed. So when you run nodemanager with a nohup appended command. It tells the server to run the process in background.
There is two ways to write the nohup command for executing scripts.
- nohup ./start.sh
The above command will create a file named nohup.out in the same folder where the logs of the execution will be written to.
- nohup ./start.sh > start_29112016.log
The above command writes to a file named start_29112016.log .
I am new to linux, so any suggestions are welcome. Please feel free to write your comments below.
No comments:
Post a Comment