A system administrator needs to start a script named long_backup.sh that will take several hours to complete. The administrator must be able to disconnect their SSH session from the server without causing the script to terminate. Which of the following commands should the administrator use?
The correct command is nohup ./long_backup.sh &. The nohup command makes the script ignore the SIGHUP (hangup) signal, which is sent to processes when the controlling terminal is closed. The & operator runs the command in the background, freeing up the terminal for other commands and allowing the user to log out.
Running the script with only & (./long_backup.sh &) will start it in the background, but it will still terminate when the session ends and the SIGHUP signal is sent.
The bg command is used to resume a stopped job in the background; it is not used to initiate a new process in this manner.
The exec command replaces the current shell with the script's process. It does not run the script in the background and will not prevent it from terminating upon logout.
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.
Why does the `nohup` command ignore the SIGHUP signal?
Open an interactive chat with Bash
What is the purpose of the `&` operator in Linux commands?
Open an interactive chat with Bash
How does `nohup` differ from the `bg` 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