XK0-005 · Question #59
An administrator needs to change the IP address on a server remotely. After updating the configuration files, a network restart is needed. However, the administrator fears that when the network…
The correct answer is A. nohup service network restart. To prevent a script from being terminated when its controlling terminal closes or a network connection drops, the nohup command should be used.
Question
An administrator needs to change the IP address on a server remotely. After updating the configuration files, a network restart is needed. However, the administrator fears that when the network connection drops, the network restart script will be killed before the new IP address has been set. Which of the following commands would prevent the script from being killed?
Options
- Anohup service network restart
- Bservice network restart &
- Cecho "service network restart" | at now
- Ddg service network restart
How the community answered
(40 responses)- A83% (33)
- B10% (4)
- C5% (2)
- D3% (1)
Why each option
To prevent a script from being terminated when its controlling terminal closes or a network connection drops, the `nohup` command should be used.
The `nohup` command runs a command immune to hangups, meaning it prevents the process from receiving the SIGHUP signal which is typically sent to processes when the controlling terminal is closed or a network connection drops, ensuring the network restart script completes.
Appending `&` to a command runs it in the background, but the process can still receive a SIGHUP signal and be terminated if the terminal session ends.
`at now` schedules a command to run immediately in a new shell environment, which might survive a session drop, but `nohup` is specifically designed to make a process immune to hangups from terminal closure or network loss.
`dg` is not a standard Linux command for preventing scripts from being killed upon session termination.
Concept tested: Process management - nohup command
Source: https://man7.org/linux/man-pages/man1/nohup.1.html
Topics
Community Discussion
No community discussion yet for this question.