To run multiple commands in the background
nohup command can be used to run multiple commands in the background.
nohup bash -c 'commands'
Example:
nohup bash -c 'cal && ls'
Output:
Here, the output will be by default stored in nohup.out. To redirect it, type:
nohup bash -c 'commands' > filename.txt
Example:
nohup bash -c 'cal && ls' > output.txt
Output:
nohup Command in Linux with Examples
Every command in Linux starts a process at the time of its execution, which automatically gets terminated upon exiting the terminal. Suppose, you are executing programs over SSH and if the connection drops, the session will be terminated, all the executed processes will stop, and you may face a huge accidental crisis. In such cases, running commands in the background can be very helpful to the user and this is where nohup command comes into the picture. nohup (No Hang Up) is a command in Linux systems that runs the process even after logging out from the shell/terminal.
Contact Us