mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Linux (https://www.mersenneforum.org/forumdisplay.php?f=39)
-   -   Keeping processes alive after logoff (https://www.mersenneforum.org/showthread.php?t=26723)

bur 2021-04-22 14:20

Keeping processes alive after logoff
 
I have a headless machine that I only access via SSH. I'm currently using tmux to keep yafu/cado etc running after I log off. Is that the best choice here?

chalsall 2021-04-22 14:29

[QUOTE=bur;576491]Is that the best choice here?[/QUOTE]

There are many options for this kind of thing, including "nohup", "session" etc.

Personally I just do something like "mprime -d >> mprime.log < /dev/null 2> /dev/null &" and then exit. This redirects STDIN, STDOUT, and STDERR so there are no file handles attached to the console, and so mprime continues its work without any problems.

Nick 2021-04-22 15:13

In general, the concepts to be aware of here are process groups, sessions and controlling terminals.
[CODE]man 7 credentials[/CODE]is one place to start.

EdH 2021-04-22 21:01

I have a headless "farm" and I use tmux for terminal type use. There is also a similar option called "screen" that works the same. For my use, I have a GUI session start and use VNC over SSH to log into the GUIs of the machines. The machines are completely headless and use an Xorg dummy setup to make the desktop machines all the same resolution. The GUI and VNC via SSH do tax the machines a little, but I like to have several terminals open in some of the GUIs.

masser 2021-04-23 01:17

I use "disown" - but I'm interested to hear better alternatives.

EdH 2021-04-23 02:45

[QUOTE=masser;576564]I use "disown" - but I'm interested to hear better alternatives.[/QUOTE]
As the OP and I mentioned, "tmux" will allow you to open a terminal that can be left running when you close the calling terminal. Basically, it works like this:

Open a terminal in the GUI or via SSH, etc.
Enter "tmux" (without quotes).
Start your program at the tmux prompt.
Use CTRL+b, then d (without the CTRL) to exit tmux and leave the called process running. (It will say that it detached.)
You can then close your calling terminal.

To get back into the session, use "tmux a" in a terminal.
To close the tmux session, use "exit." (It will say that it exited.)

"screen" works very much the same way and both have a lot more functionality, as described in their docs, such as multiple panes within a session.

Batalov 2021-04-23 04:26

[QUOTE=masser;576564]I use "disown" - but I'm interested to hear better alternatives.[/QUOTE]
[C]disown -a [/C] is just as good as not forgetting to add [C]nohup[/C] some short time ago.

"just do it" (as often as you want) and you will be golden.

bur 2021-04-23 06:56

Ok thanks, I'll keep using tmux for now.

This [I]mprime -d >> mprime.log < /dev/null 2> /dev/null &[/I] seems elegant in that it doesn't rely on any other additional software. I have to admit I don't understand half of the > ... :)

paulunderwood 2021-04-23 07:02

[QUOTE=bur;576589]Ok thanks, I'll keep using tmux for now.

This [I]mprime -d >> mprime.log < /dev/null 2> /dev/null &[/I] seems elegant in that it doesn't rely on any other additional software. I have to admit I don't understand half of the > ... :)[/QUOTE]

> is redirect output to
>> is append output to
< get input from

2 is std error?

chalsall 2021-04-23 14:13

[QUOTE=paulunderwood;576590]2 is std error?[/QUOTE]

Yup. 2> is STDERR, while > is STDOUT.

I could have also done "2>&1" to redirect STDERR to STDOUT, but I tend not to use that because it is less obvious what's going on, and it uses the "&" symbol which is used later in the command string to throw the process into the background.

masser 2021-04-23 15:35

[QUOTE=EdH;576568]
Open a terminal in the GUI or via SSH, etc.
Enter "tmux" (without quotes).
Start your program at the tmux prompt.
Use CTRL+b, then d (without the CTRL) to exit tmux and leave the called process running. (It will say that it detached.)
You can then close your calling terminal.

To get back into the session, use "tmux a" in a terminal.
To close the tmux session, use "exit." (It will say that it exited.)
[/QUOTE]

Many thanks, EdH. You too, Batalov. I just went through the sequence above (had to install tmux first) and it works great.


All times are UTC. The time now is 01:53.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.