You connect to server1 over SSH and need to run make all, a compilation that can last several hours. The job has three requirements: it must survive if you log out or the network drops, both standard output and standard error must be appended to a file named compile.log in the current directory, and the shell prompt should return immediately so you can continue working. Using only standard shell utilities available on a typical Linux system, which single Bash command meets all of these requirements?
nohup makes the child process ignore the SIGHUP signal that a login shell sends to its jobs when the controlling terminal closes; this keeps the build alive after logout. Appending & backgrounds the job so the prompt returns right away. The redirection sequence >> compile.log 2>&1 appends ( >> ) both stdout and stderr ( 2>&1 ) to compile.log as required.
The other choices each fail at least one goal:
nohup make all > compile.log 2>&1 & uses the > operator, which overwrites compile.log instead of appending to it.
nohup make all 2>> compile.log & correctly appends, but it only captures standard error (2>>); standard output would still go to the default nohup.out file.
make all & disown -h can also prevent the job from being terminated by SIGHUP, but it fails to redirect any output to the compile.log file.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the `nohup` command?
Open an interactive chat with Bash
What does `>> compile.log 2>&1` do specifically?
Open an interactive chat with Bash
Why is the `&` symbol used at the end of the command?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access