* [gentoo-user] Running a program on a headless computer ?
@ 2014-09-28 14:13 meino.cramer
2014-09-28 14:22 ` Randolph Maaßen
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: meino.cramer @ 2014-09-28 14:13 UTC (permalink / raw
To: Gentoo
Hi,
I want to run programs, which insist on haveing a terminal
to write their status to and which are writing files which
their results on a headless computer (beaglebone).
I tried things like
my_program -o file.txt -parameter value > /dev/null &2>&1 &
but this results in a idle copy of this process and a defunct
child.
The program does not use X11 in any way...
Is there any neat trick to accomplish what I am trying to do here?
Thank you very much in advance for any help!
Best regards,
mcc
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
@ 2014-09-28 14:22 ` Randolph Maaßen
2014-09-28 16:08 ` meino.cramer
2014-09-28 16:18 ` Stroller
2014-09-28 18:43 ` Neil Bothwick
` (3 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Randolph Maaßen @ 2014-09-28 14:22 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 820 bytes --]
On Sep 28, 2014 4:14 PM, <meino.cramer@gmx.de> wrote:
>
> Hi,
>
> I want to run programs, which insist on haveing a terminal
> to write their status to and which are writing files which
> their results on a headless computer (beaglebone).
>
> I tried things like
>
> my_program -o file.txt -parameter value > /dev/null &2>&1 &
>
> but this results in a idle copy of this process and a defunct
> child.
>
> The program does not use X11 in any way...
>
> Is there any neat trick to accomplish what I am trying to do here?
>
> Thank you very much in advance for any help!
> Best regards,
> mcc
>
>
>
I would suggest to run the program in a screen session, you can disconnect
frim the session and reconnect later.
http://www.gnu.org/software/screen/
--
Best regards
Randolph Maaßen
[-- Attachment #2: Type: text/html, Size: 1184 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:22 ` Randolph Maaßen
@ 2014-09-28 16:08 ` meino.cramer
2014-09-28 16:24 ` Randolph Maaßen
` (2 more replies)
2014-09-28 16:18 ` Stroller
1 sibling, 3 replies; 14+ messages in thread
From: meino.cramer @ 2014-09-28 16:08 UTC (permalink / raw
To: gentoo-user
Randolph Maaßen <r.maassen60@gmail.com> [14-09-28 16:24]:
> On Sep 28, 2014 4:14 PM, <meino.cramer@gmx.de> wrote:
> >
> > Hi,
> >
> > I want to run programs, which insist on haveing a terminal
> > to write their status to and which are writing files which
> > their results on a headless computer (beaglebone).
> >
> > I tried things like
> >
> > my_program -o file.txt -parameter value > /dev/null &2>&1 &
> >
> > but this results in a idle copy of this process and a defunct
> > child.
> >
> > The program does not use X11 in any way...
> >
> > Is there any neat trick to accomplish what I am trying to do here?
> >
> > Thank you very much in advance for any help!
> > Best regards,
> > mcc
> >
> >
> >
>
> I would suggest to run the program in a screen session, you can disconnect
> frim the session and reconnect later.
>
> http://www.gnu.org/software/screen/
>
> --
> Best regards
> Randolph Maaßen
Hi Randolph,
...the headless device will be booted and the programm will be startet
via a kind of autostart script. No human intervention is
wanted/possible...
Best regards,
mcc
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:22 ` Randolph Maaßen
2014-09-28 16:08 ` meino.cramer
@ 2014-09-28 16:18 ` Stroller
1 sibling, 0 replies; 14+ messages in thread
From: Stroller @ 2014-09-28 16:18 UTC (permalink / raw
To: gentoo-user
On Sun, 28 September 2014, at 3:22 pm, Randolph Maaßen <r.maassen60@gmail.com> wrote:
> ...
> I would suggest to run the program in a screen session, you can disconnect frim the session and reconnect later.
>
> http://www.gnu.org/software/screen/
If someone has never used `screen` before, I recommend using `tmux` instead.
It has innumerable small improvements over `screen` and is very actively maintained.
Stroller.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 16:08 ` meino.cramer
@ 2014-09-28 16:24 ` Randolph Maaßen
2014-09-28 16:47 ` Stroller
2014-09-28 17:07 ` Jc García
2 siblings, 0 replies; 14+ messages in thread
From: Randolph Maaßen @ 2014-09-28 16:24 UTC (permalink / raw
To: gentoo-user
2014-09-28 18:08 GMT+02:00 <meino.cramer@gmx.de>:
>
> Randolph Maaßen <r.maassen60@gmail.com> [14-09-28 16:24]:
>> On Sep 28, 2014 4:14 PM, <meino.cramer@gmx.de> wrote:
>> >
>> > Hi,
>> >
>> > I want to run programs, which insist on haveing a terminal
>> > to write their status to and which are writing files which
>> > their results on a headless computer (beaglebone).
>> >
>> > I tried things like
>> >
>> > my_program -o file.txt -parameter value > /dev/null &2>&1 &
>> >
>> > but this results in a idle copy of this process and a defunct
>> > child.
>> >
>> > The program does not use X11 in any way...
>> >
>> > Is there any neat trick to accomplish what I am trying to do here?
>> >
>> > Thank you very much in advance for any help!
>> > Best regards,
>> > mcc
>> >
>> >
>> >
>>
>> I would suggest to run the program in a screen session, you can disconnect
>> frim the session and reconnect later.
>>
>> http://www.gnu.org/software/screen/
>>
>> --
>> Best regards
>> Randolph Maaßen
>
> Hi Randolph,
>
> ...the headless device will be booted and the programm will be startet
> via a kind of autostart script. No human intervention is
> wanted/possible...
This is possilble with screen. yust start a screen session in your script
screen -dmS "SessionName"
and run the program you want
screen -S "SessionName" -p 0 -X stuff "$program\n"
where -p gives the screen window number
>
> Best regards,
> mcc
>
>
>
--
Mit freundlichen Grüßen / Best regards
Randolph Maaßen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 16:08 ` meino.cramer
2014-09-28 16:24 ` Randolph Maaßen
@ 2014-09-28 16:47 ` Stroller
2014-09-28 17:06 ` meino.cramer
2014-09-28 17:07 ` Jc García
2 siblings, 1 reply; 14+ messages in thread
From: Stroller @ 2014-09-28 16:47 UTC (permalink / raw
To: gentoo-user
On Sun, 28 September 2014, at 5:08 pm, meino.cramer@gmx.de wrote:
>>> ...
>>> I want to run programs, which insist on haveing a terminal
>>> to write their status to and which are writing files which
>>> their results on a headless computer (beaglebone).
>>
>> I would suggest to run the program in a screen session, you can disconnect
>> frim the session and reconnect later.
>
> ...the headless device will be booted and the programm will be startet
> via a kind of autostart script. No human intervention is
> wanted/possible...
It's certainly possible to write such scripts to start automatically.
E.G. from tmux's manpage:
tmux new-session -d 'vi /etc/passwd' \; split-window -d \; attach
Tested here:
#!/bin/bash
tmux new-session -n meino -d
tmux send -t meino ls ENTER
You would be able to access this:
$ tmux list-w
0: meino* (1 panes) [80x39] [layout c85d,80x39,0,0,0] @0 (active)
$ tmux a
I'm not saying that a terminal multiplexer is the best way to solve your problem - I don't understand why the output of your program is not directable to a text file - but it's definitely possible to script the process of running a program in a terminal multiplexer window or session.
You could write a script to see if a specific named session exists, and start one if it doesn't. You could then call this every 5 minutes in cron.
Note that, in the example above I've named the window "meino" - I think you might be advised to name both window and session. You can attach sessions by name.
I referred to this page: http://serverfault.com/questions/339390/run-command-in-detached-tmux-session
It's a top google hit for "run command in tmux"
Stroller.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 16:47 ` Stroller
@ 2014-09-28 17:06 ` meino.cramer
0 siblings, 0 replies; 14+ messages in thread
From: meino.cramer @ 2014-09-28 17:06 UTC (permalink / raw
To: gentoo-user
Stroller <stroller@stellar.eclipse.co.uk> [14-09-28 18:52]:
>
> On Sun, 28 September 2014, at 5:08 pm, meino.cramer@gmx.de wrote:
> >>> ...
> >>> I want to run programs, which insist on haveing a terminal
> >>> to write their status to and which are writing files which
> >>> their results on a headless computer (beaglebone).
> >>
> >> I would suggest to run the program in a screen session, you can disconnect
> >> frim the session and reconnect later.
> >
> > ...the headless device will be booted and the programm will be startet
> > via a kind of autostart script. No human intervention is
> > wanted/possible...
>
> It's certainly possible to write such scripts to start automatically.
>
> E.G. from tmux's manpage:
>
> tmux new-session -d 'vi /etc/passwd' \; split-window -d \; attach
>
> Tested here:
>
> #!/bin/bash
> tmux new-session -n meino -d
> tmux send -t meino ls ENTER
>
> You would be able to access this:
>
> $ tmux list-w
> 0: meino* (1 panes) [80x39] [layout c85d,80x39,0,0,0] @0 (active)
> $ tmux a
>
>
> I'm not saying that a terminal multiplexer is the best way to solve your problem - I don't understand why the output of your program is not directable to a text file - but it's definitely possible to script the process of running a program in a terminal multiplexer window or session.
>
> You could write a script to see if a specific named session exists, and start one if it doesn't. You could then call this every 5 minutes in cron.
>
> Note that, in the example above I've named the window "meino" - I think you might be advised to name both window and session. You can attach sessions by name.
>
> I referred to this page: http://serverfault.com/questions/339390/run-command-in-detached-tmux-session
> It's a top google hit for "run command in tmux"
>
> Stroller.
>
I tried to redirect the output, which technically is comparable with what
can be seen by running "top". The result as mentioned is a somewhat
locked process and its zombie child.
Starting of whatever will accomplish what I am trying to do is already
implemented (somewhow uglyish...;) and works...beside of the
sideeffect that the program goes zombie.
I definately will try the screen or tmux version (or both ;) ) !
Thank you very much for all help !
Best regards,
mcc
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 16:08 ` meino.cramer
2014-09-28 16:24 ` Randolph Maaßen
2014-09-28 16:47 ` Stroller
@ 2014-09-28 17:07 ` Jc García
2 siblings, 0 replies; 14+ messages in thread
From: Jc García @ 2014-09-28 17:07 UTC (permalink / raw
To: gentoo-user
2014-09-28 10:08 GMT-06:00 <meino.cramer@gmx.de>:
>
> Randolph Maaßen <r.maassen60@gmail.com> [14-09-28 16:24]:
>> On Sep 28, 2014 4:14 PM, <meino.cramer@gmx.de> wrote:
>> >
>> > Hi,
>> >
>> > I want to run programs, which insist on haveing a terminal
>> > to write their status to and which are writing files which
>> > their results on a headless computer (beaglebone).
>> >
>> > I tried things like
>> >
>> > my_program -o file.txt -parameter value > /dev/null &2>&1 &
>> >
>> > but this results in a idle copy of this process and a defunct
>> > child.
>> >
>> > The program does not use X11 in any way...
>> >
>> > Is there any neat trick to accomplish what I am trying to do here?
>> >
>> > Thank you very much in advance for any help!
>> > Best regards,
>> > mcc
>> >
>> >
>> >
>>
>> I would suggest to run the program in a screen session, you can disconnect
>> frim the session and reconnect later.
>>
>> http://www.gnu.org/software/screen/
>>
>> --
>> Best regards
>> Randolph Maaßen
>
> Hi Randolph,
>
> ...the headless device will be booted and the programm will be startet
> via a kind of autostart script. No human intervention is
> wanted/possible...
>
You can use ">&-" in the script to run the program with stdout closed
by default, but this might result in an error if the program relies on
stdout open example:
---
$ echo "Hello" >&-
bash: echo: write error: Bad file descriptor
---
but if I do this(stdout and stderr closed):
--
$ echo "Hello" 2>&- >&-
--
nothing is printed
but
--
$ echo $?
1
--
However if I try to run an application that uses X it starts normally.
more info on this stuff on [1]
in page 15 it's kind of explained the case of programs running with ">&-"
https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
> Best regards,
> mcc
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
2014-09-28 14:22 ` Randolph Maaßen
@ 2014-09-28 18:43 ` Neil Bothwick
2014-09-30 9:46 ` meino.cramer
2014-09-28 19:15 ` Todd Goodman
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Neil Bothwick @ 2014-09-28 18:43 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
On Sun, 28 Sep 2014 16:13:51 +0200, meino.cramer@gmx.de wrote:
> I want to run programs, which insist on haveing a terminal
> to write their status to and which are writing files which
> their results on a headless computer (beaglebone).
>
> I tried things like
>
> my_program -o file.txt -parameter value > /dev/null &2>&1 &
>
> but this results in a idle copy of this process and a defunct
> child.
nohup may do what you want.
Or you can do it with at, if atd is running
echo "my_program -o file.txt -parameter value" | at now
--
Neil Bothwick
A wok is what you throw at a wabbit.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
2014-09-28 14:22 ` Randolph Maaßen
2014-09-28 18:43 ` Neil Bothwick
@ 2014-09-28 19:15 ` Todd Goodman
2014-09-28 22:34 ` Sid S
2014-09-28 23:12 ` Kerin Millar
2014-09-29 15:36 ` [gentoo-user] " James
4 siblings, 1 reply; 14+ messages in thread
From: Todd Goodman @ 2014-09-28 19:15 UTC (permalink / raw
To: gentoo-user
* meino.cramer@gmx.de <meino.cramer@gmx.de> [140928 10:14]:
> Hi,
>
> I want to run programs, which insist on haveing a terminal
> to write their status to and which are writing files which
> their results on a headless computer (beaglebone).
>
> I tried things like
>
> my_program -o file.txt -parameter value > /dev/null &2>&1 &
>
> but this results in a idle copy of this process and a defunct
> child.
>
> The program does not use X11 in any way...
>
> Is there any neat trick to accomplish what I am trying to do here?
>
> Thank you very much in advance for any help!
> Best regards,
> mcc
You probably want 2>&1 &
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 19:15 ` Todd Goodman
@ 2014-09-28 22:34 ` Sid S
0 siblings, 0 replies; 14+ messages in thread
From: Sid S @ 2014-09-28 22:34 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]
I was deciding whether to reply earlier, and my worst fears were realized:
you plan to start this automatically with no human intervention.
Here is a snippet which should do what you want: `nohup my-program >
/dev/null 2>&1 &`
Screen and tmux will/should work, but at the very least I would suggest
wrapping the program with a program of your own where you execute the other
and have more and explicit control over the file descriptors.
The best solution is modifying your programs to work headlessly. This also
means you can ensure logging is done properly (you were logging, right?),
and not in some ad-hoc fashion like reading all the messages your black box
produces and keeping the ones that "look important."
It's tempting to glue some things together with the shell, but I would
avoid reliance on programs which are not yours as much as possible. "Not
Invented Here" is often (rightfully) mocked, but this is one of the
situations in which it has some relevance.
On Sun, Sep 28, 2014 at 2:15 PM, Todd Goodman <tsg@bonedaddy.net> wrote:
> * meino.cramer@gmx.de <meino.cramer@gmx.de> [140928 10:14]:
> > Hi,
> >
> > I want to run programs, which insist on haveing a terminal
> > to write their status to and which are writing files which
> > their results on a headless computer (beaglebone).
> >
> > I tried things like
> >
> > my_program -o file.txt -parameter value > /dev/null &2>&1 &
> >
> > but this results in a idle copy of this process and a defunct
> > child.
> >
> > The program does not use X11 in any way...
> >
> > Is there any neat trick to accomplish what I am trying to do here?
> >
> > Thank you very much in advance for any help!
> > Best regards,
> > mcc
>
> You probably want 2>&1 &
>
>
[-- Attachment #2: Type: text/html, Size: 2428 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
` (2 preceding siblings ...)
2014-09-28 19:15 ` Todd Goodman
@ 2014-09-28 23:12 ` Kerin Millar
2014-09-29 15:36 ` [gentoo-user] " James
4 siblings, 0 replies; 14+ messages in thread
From: Kerin Millar @ 2014-09-28 23:12 UTC (permalink / raw
To: gentoo-user
On 28/09/2014 15:13, meino.cramer@gmx.de wrote:
> Hi,
>
> I want to run programs, which insist on haveing a terminal
> to write their status to and which are writing files which
> their results on a headless computer (beaglebone).
>
> I tried things like
>
> my_program -o file.txt -parameter value > /dev/null &2>&1 &
>
> but this results in a idle copy of this process and a defunct
> child.
>
> The program does not use X11 in any way...
>
> Is there any neat trick to accomplish what I am trying to do here?
Take a look at daemonize. It is available in portage.
http://software.clapper.org/daemonize/
--Kerin
^ permalink raw reply [flat|nested] 14+ messages in thread
* [gentoo-user] Re: Running a program on a headless computer ?
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
` (3 preceding siblings ...)
2014-09-28 23:12 ` Kerin Millar
@ 2014-09-29 15:36 ` James
4 siblings, 0 replies; 14+ messages in thread
From: James @ 2014-09-29 15:36 UTC (permalink / raw
To: gentoo-user
<meino.cramer <at> gmx.de> writes:
> I want to run programs, which insist on haveing a terminal
> to write their status to and which are writing files which
> their results on a headless computer (beaglebone).
> Is there any neat trick to accomplish what I am trying to do here?
> mcc
Hello meino,
Back when dinosaurs (like me) roamed the halls of academia,
we use to send things out the serial console, to something
like a VT100 "dumb terminal" both the video and the keyboard
would attached to the computer's serial port. You could just
power down the display for weeks at a time, and power it up
to see what activity was currently being piped to the standard
output.....
If you can find an old "VT100" or ibm or other brands (can't remember the
names, but dec, HP and many others made them" that will work.
I've also have a home built "serial data analyzer" that plugs
into a serial port, for a blazing 19,200 buad 2 line ascii serial
terminal, but it is buried somewhere in my lab.....
I have even piped things out one seria console l port (on a headless system)
into the serial port of another pc (usually crossing 2 & 3 pins
in some from of a "null modem". In fact at one point I has many serial
ports on one pc brining in console outputs from many headless Sun servers,
for logging. Some "night-mare" I inherited as a graduate student,
back when the gasses where coalescing......
Thanks for the trip down memory lane......
hth,
James
[1] http://www.vanemery.com/Linux/Serial/serial-console.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-user] Running a program on a headless computer ?
2014-09-28 18:43 ` Neil Bothwick
@ 2014-09-30 9:46 ` meino.cramer
0 siblings, 0 replies; 14+ messages in thread
From: meino.cramer @ 2014-09-30 9:46 UTC (permalink / raw
To: gentoo-user
Neil Bothwick <neil@digimed.co.uk> [14-09-28 20:44]:
> On Sun, 28 Sep 2014 16:13:51 +0200, meino.cramer@gmx.de wrote:
>
> > I want to run programs, which insist on haveing a terminal
> > to write their status to and which are writing files which
> > their results on a headless computer (beaglebone).
> >
> > I tried things like
> >
> > my_program -o file.txt -parameter value > /dev/null &2>&1 &
> >
> > but this results in a idle copy of this process and a defunct
> > child.
>
> nohup may do what you want.
>
> Or you can do it with at, if atd is running
>
> echo "my_program -o file.txt -parameter value" | at now
>
>
> --
> Neil Bothwick
>
> A wok is what you throw at a wabbit.
Hi all,
first of all: Thanks a lot for all offered help and the various
suggested method to acchieve what I wanted... :)
Since the device I use is an embedded system (Beaglebone black) memory
consumption of the software is more important as it is on a fully
blown PC...
The 'nohup' method works for me like a charm! And it is straight
forward and uses less memory.
Best regards,
mcc
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-09-30 9:46 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-28 14:13 [gentoo-user] Running a program on a headless computer ? meino.cramer
2014-09-28 14:22 ` Randolph Maaßen
2014-09-28 16:08 ` meino.cramer
2014-09-28 16:24 ` Randolph Maaßen
2014-09-28 16:47 ` Stroller
2014-09-28 17:06 ` meino.cramer
2014-09-28 17:07 ` Jc García
2014-09-28 16:18 ` Stroller
2014-09-28 18:43 ` Neil Bothwick
2014-09-30 9:46 ` meino.cramer
2014-09-28 19:15 ` Todd Goodman
2014-09-28 22:34 ` Sid S
2014-09-28 23:12 ` Kerin Millar
2014-09-29 15:36 ` [gentoo-user] " James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox