I have a .jar file which is console based. I would like to run it in Linux via SSH. So far I am able to run it and see the output.

However, after disconnecting and then reconnecting to the terminal, how can I access the output from the Java program again?

  • minecraft server remote administration?
    – dashboard
    Commented Apr 5, 2013 at 2:36
  • ha nice guess!, though i play minecraft, not rly that ;)
    – Krimson
    Commented Apr 5, 2013 at 3:04

2 Answers 2


Do you want to leave the Java application running, even after you disconnect? If so, install screen. screen allows you to create persistent sessions allowing you to keep programs/scripts running in their own session even after you log out of SSH.

If you're on Ubuntu or any Debian-based distro, installing screen is easy:

# apt-get install screen

To create a session:

$ screen -R sessionName

Start your Java application in the session and then when you are ready to detach and let it run in the background, type Ctrl+A and then D. You can then safely disconnect from the SSH session.

To re-attach to the screen session, execute:

$ screen -r sessionName

The Screen man pages describe all of the other arguments and flags if you want to learn more.

If you simply want to save the output of the application for later reading, redirect stdout to a file:

$ java -jar my.jar > output.txt
  • your instructions were a breeze to follow through! Well written!
    – Krimson
    Commented Apr 5, 2013 at 3:08
  • You are really Awesome man Mr. Rain... Thanks a lot. Commented Mar 11, 2016 at 11:25

alternately you could also use Tmux, a more modern alternative to screen

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .