3

I'm trying to run several compute intensive python scripts on a server (Ubuntu 14.04.5 LTS) via ssh -Y and tmux. This works fine as long as I don't close the ssh connection. If I do close the connection, the currently running script will finish properly but the all scripts starting afterwards will get the error

gtk-WARNING **: cannot open display: localhost:10.0

The scripts are command-line-only but perhaps a library used for some reason needs a display. If I disconnect, the display is gone (my assumption). Is there a way to fix this (preferably without root access), perhaps a way to fool ubuntu into thinking there's a display while there is none?

EDIT:

  • I first connect to a vpn and then ssh into the server (with -Y flag)
  • I'm trying to run this script in a loop with different parameters each time. It uses matplotlib.use('Agg') so matplotlib shouldn't be the problem (?) I can't think of anything else.
  • echo $DISPLAY returns localhost:10.0 before the error. If I connect from a different computer it returns localhost:13.0. If I left the terminal on the original computer open, it will still return localhost:10.0 however if I open a new one it will now also return localhost:13.0
  • X11-Forwarding works normally, I can run any desktop app I tried so far. The problem are scripts that start after I disconnect/logout.
  • can you tell me what does echo $DISPLAY command return after you see that error? – Savvas Radevic Feb 4 '18 at 12:27
  • also, what kind of commands are you trying to run? gtk-warning shows you're trying to run desktop apps in a terminal.. does the command/app support command-line mode? Possible solution here: superuser.com/a/310201/76384 – Savvas Radevic Feb 4 '18 at 12:38
  • @SavvasRadevic Thank You for trying to help me! echo $DISPLAY returns localhost:10.0 before the error. If I connect from a different computer it returns localhost:13.0. If I left the terminal on the original computer open, it will still return localhost:10.0 however if I open a new one it will now also return localhost:13.0. Could intermittently connecting from a different computer be the problem? However the script seems to have already failed before I connect again (not sure though) – KJoke Feb 4 '18 at 13:26
0

Try setting the DISPLAY variable:

export DISPLAY=localhost:10.0

And then execute your commands.

  • 1
    Wouldn't this be better if written as a comment first and then posted as a more detailed answer if it works for OP? – WinEunuuchs2Unix Feb 5 '18 at 12:43
  • Thank you for the recommendation, however I believe it requires an exception to that rule as it is a sane solution. Plus it won't get lost in the sea of comments. :) – Savvas Radevic Feb 6 '18 at 14:55
  • This does not work. As I said, X11-Forwarding works fine, what I need is a way to schedule scripts that require x-server without the need to be constantly connected. Scripts which start after I close the connection fail because the display at localhost:10.0 is no longer accessible. Something like this should work, unfortunately I don't have the rights to install packages and can't test it. – KJoke Feb 15 '18 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.