How Do You Prevent a Process from Ending Due to a User Logging Off?

Problem scenario
You want a process to keep running on a Linux server.  But when the user who starts it logs off, the process ends.  How do you allow the user to log off but obviate the logging off from terminating (through signaling termination) of that process you want to remain running?

Have the user use the nohup command to execute the important process.  As an example imagine that the process that is important is running ""  Here is how to use nohup:

nohup bash

You may get a message like this in response:  "nohup: ignoring input and appending output to 'nohup.out'"

This is normal.  However, the process may appear to hang. So it is often advisable to send the command to the background with an "&" symbol (because commands that involve a user logging off tend to have a long duration):

nohup bash &

If the user session, the one that ran the "nohup" command (like either of the above), ends (e.g., the user logs off or a system administrator kills the session), the process for will continue.  If is a long-running and important process, the nohup command can be of great help.

Leave a comment

Your email address will not be published. Required fields are marked *