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'm connecting to my web host from Windows 7 using putty ssh. When I start a script in the remote host, sometimes I get disconnected. I have to connect again, and from the command "ps aux" I can see that my script is still running, but I don't have the outputs on terminal anymore.

How can I see the script outputs after re-logging?

Thank you.

share|improve this question

3 Answers 3

You should consider running GNU Screen after logging in via ssh. There's a ton you can do from there, which you can read about on the net. The basic functionality will give you a new shell which will (magically) continue to run even after you've closed your putty window.

When you reconnect to the server, just start screen with the "-R" option and you'll reconnect to your existing session. Magic.

It's likely already installed on your system; try typing "screen" at the shell prompt.

Once you start to use screen you'll wonder how you lived without it. For an enhanced screen experience, try "byobu". It's preinstalled on newer versions of Ubuntu.

share|improve this answer

You cannot without installing/configuring additional software, but alternatively you could redirect the output of the script to a log file and watch that log file after the script has completed or while it is running by executing this command to execute your script:

myscript.sh > ~/scriptlog.log

The outputs will then be written to scriptlog.log in your home directory.

As The Journeyman Geek stated in his comment:

You can then watch the log file in near realtime with

tail scriptlog.log
share|improve this answer
1  
Screen - 3rd party?? –  Linker3000 Feb 10 '11 at 23:35
    
@Linker3000 I meant additional xD but couldn't find the correct word when writing my edit... –  BloodPhilia Feb 10 '11 at 23:37
1  
you can then watch the log file in near realtime with 'tail scriptlog.log' –  Journeyman Geek Feb 11 '11 at 0:00
    
or (possibly) even better; tail -f scriptlog.log –  Eroen Apr 20 '12 at 22:43

If you don't need the features or want the overhead of any of these typical tools for managing detachable processes:

  • GNU screen
  • byobu
  • dtach
  • tmux
  • vnc
  • xpra

you can keep track of the output from a process by prefixing your command with nohup when you start it up. By default, it will save both standard output and standard error to nohup.out, but see the man page for additional details.

nohup won't let you interact with the process once it's been detached, but it will allow the script to complete and allow you to view the output after the fact. For more complex cases, such as long-running interactive processes or X clients, you may want to look at one of the other tools listed and see if they fit your needs better.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.