Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have access to a remote Linux shell for work purposes. I have kept a python script running in the background using nohup.

Now, if I want to exit the session, what is the difference between using logout and exit commands? Will my script keep running in both of these cases?

share|improve this question
1  
I find it better to use screen when I want to make sure console processes live on after I'm gone. –  Marcelo Cantos Jul 25 '11 at 12:01
add comment

migrated from stackoverflow.com Jul 25 '11 at 16:26

This question came from our site for professional and enthusiast programmers.

2 Answers

logout is an internal command of the shell. So generally the answer is shell-dependent. From man bash:

logout – Exit a login shell.

From man zsh:

logout [ n ] – Same as exit, except that it only works in a login shell.

So they're completely the same, but logout will simply refuse to work for non-login shells. What is a login shell can be read in manual pages.

share|improve this answer
    
exit is an internal command of the shell, too. –  Paŭlo Ebermann Jul 25 '11 at 15:49
1  
(Also: I don't see the point of having a exit-like command which only works for login shells. The other way around would be more useful (e.g. "exit only if not in a login shell").) –  Paŭlo Ebermann Jul 25 '11 at 15:50
add comment

Try both in your local terminal. If you want use "logout", you need be "login". In your terminal by default you never start the shell with login, so if you want close the terminal you need use "exit". It isn't a "login shell".

In remote ssh shell is indifferent because you're using a "login shell". When you use nohub or similar, you are "detach" the command from the actual shell, so when you close your shell the process doesn't die.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.