I have to run some programs on a shared workstation with x2go.
These programs take quite some time and I wish to:
- Start the program within x2go
- Log out
- Connect again after some time to the machine with x2go and see the results of the program
So, in the end, what I would like to do is similar to what one can do with screen
. However, it seems that logging out kills all the programs running.
The programs use Mathematica and in particular some of its dynamic built-in functions, so I need access to the X-server in order to interact with the GUI and screen
is not an option.
If needed, both my computer and the workstation use Ubuntu. The command cat /etc/os-release
give:
My computer
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Workstation
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
It cannot be done the way you propose:
As you have discovered when a GUI session ends, the display server is terminated (not suspended or hidden), and all child jobs are also terminated. That behavior is fundamental to logout.
Even if you did something fancy (like
nohup
) to keep your window alive, it would promptly error since there's no display anymore.Developers facing this situation generally build two programs that talk to each other: One that doesn't require a display, and thus can persist using a terminal multiplexor (
screen
,tmux
) or simply as a systemd service, cronjob, atjob, etc. And a second program that provides the intermittent graphical interface to the longer-running headless job.You seem to have two alternatives: Keep your GUI session alive until completion, or rewrite your code to not require a display at all times.