You may have encountered some commands which take a while to complete processing. There are some tricks that could help gain control once you launch the command so that you can do other things meanwhile.
1 – First you can append the sign ‘&’ to the end of command so that it will run in the background as follows:
You can hit Ctrl+Z in order to suspend it. To put it in the background, use the ‘bg’ tool:
2 – The command below :
nohup your_command &
Will run the process in background but it also generates a log ( nohup.out in your current directory or in your home directory otherwise).
Furthermore, if you exit your current shell, the process is not killed.
3 – Using also disown as shown below :
The process here will detach itself from the current shell so that you can carry out other tasks….
4 – Redirection. The command :
your_command > output_file.log 2>&1 &
This will launch the process related to your command and redirect stdout and stderr to a file output.log. In case you do not need the output, you can replace the output file with /dev/null.
The sign ‘&’ if for background processing .
2>&1 is used to redirect stderr to stdout so that the output can be retrieved.
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.