You are not logged in.

#1 2012-04-23 22:14:26

Huskehn
Member
Registered: 2012-02-06
Posts: 13

Redirect input/output of a program and view it at any time?

I'll start by saying I don't have a complete understanding of how I/O works in Linux terminals. I have a game server set up, and to run it, I execute the server .jar file. This then causes the server software to use the current screen for I/O (I'm not running an X server - I don't want a GUI). Is there any way I can sort of redirect this I/O in a way that I can access it at any time from SSH and interact with it? Any help would be very greatly appreciated. Thank you!

Offline

#2 2012-04-23 22:25:14

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: Redirect input/output of a program and view it at any time?

I am not sure, but you may be looking for GNU Screen

Last edited by ewaller (2012-04-23 22:25:29)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-04-23 22:31:29

Huskehn
Member
Registered: 2012-02-06
Posts: 13

Re: Redirect input/output of a program and view it at any time?

ewaller wrote:

I am not sure, but you may be looking for GNU Screen

This seems like what I need. I'm looking through the man pages now. Thanks!

So, with this, I would run my game server with "screen" preceding the command, and then it should create a new screen for it, and I can connect to that screen any time? Is that correct?

Offline

#4 2012-04-23 22:46:52

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: Redirect input/output of a program and view it at any time?

I believe that is correct.  To be perfectly honest, I have only researched the product, not used it.  I have, however, seen great praise for it on these forums from users I respect.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2012-04-23 22:57:54

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: Redirect input/output of a program and view it at any time?

When you say input/output, what exactly do you mean? Read/write speeds, network, upload speed, what?


Because you can probably SSH and run iotop. It's just like top but for disk writes.

You can also tail a log file and see the changes being made as they happen (if the game server provides logs, of course).


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#6 2012-04-24 00:04:52

Huskehn
Member
Registered: 2012-02-06
Posts: 13

Re: Redirect input/output of a program and view it at any time?

DSpider wrote:

When you say input/output, what exactly do you mean? Read/write speeds, network, upload speed, what?


Because you can probably SSH and run iotop. It's just like top but for disk writes.

You can also tail a log file and see the changes being made as they happen (if the game server provides logs, of course).

By input/output, I meant that of a specific program. I've figured this out with screen - it does just what I want. However, now I'm having another problem. My /etc/rc.local contains this to start the game server:

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

su - huskehn -c "cd /home/huskehn/minecraft/server/; screen -S minecraft java -Xms1G -Xmx1G -jar minecraft_server.jar nogui"

The purpose of the script is to cd to the game server's directory and create a new screen, as my user and not as root, and execute the game server within the screen (that's the java command and everything after it). If I run this script by logging in and typing /etc/./rc.local, it works just as I want it to and the game server starts. However, on system boot, it doesn't seem to run. The game server never starts. Is there some kind of log I can view that could tell me why this is happening?

Last edited by Huskehn (2012-04-24 00:06:02)

Offline

#7 2012-04-24 03:40:51

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: Redirect input/output of a program and view it at any time?

do yourself a favor and use tmux.

https://wiki.archlinux.org/index.php/Tmux

... screen has a terrible config, terrible footprint, and is terribly dead.

don't try to run everything from the rc.local script -- create a script and run that:

#!/bin/bash

exec 1> /path/to/stdout/file
exec 2> /path/to/stderr/file
set > /path/to/variable/dump

[ ... tmux commands here ... ]

chmod +x it, run it from rc.local (run the script itself, using su), then review the output ... possibly unwanted info ... but systemd makes this *very* easy.

Last edited by extofme (2012-04-24 03:49:55)


what am i but an extension of you?

Offline

#8 2012-04-25 03:30:11

Huskehn
Member
Registered: 2012-02-06
Posts: 13

Re: Redirect input/output of a program and view it at any time?

extofme wrote:

do yourself a favor and use tmux.

https://wiki.archlinux.org/index.php/Tmux

... screen has a terrible config, terrible footprint, and is terribly dead.

don't try to run everything from the rc.local script -- create a script and run that:

#!/bin/bash

exec 1> /path/to/stdout/file
exec 2> /path/to/stderr/file
set > /path/to/variable/dump

[ ... tmux commands here ... ]

chmod +x it, run it from rc.local (run the script itself, using su), then review the output ... possibly unwanted info ... but systemd makes this *very* easy.

All of my problems were fixed by using tmux instead of screen. Tmux is fantastic. Thank you!

Offline

#9 2012-04-25 05:29:40

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: Redirect input/output of a program and view it at any time?

Good to hear you've resolved the issue.

Don't forget to mark your thread as [SOLVED].


Burninate!

Offline

Board footer

Powered by FluxBB