LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2020, 10:06 AM   #1
bbarker88
LQ Newbie
 
Registered: Mar 2020
Posts: 6

Rep: Reputation: Disabled
Question Keeping a program running on Linux server when computer goes to sleep?


Hello, I have a CentOS 8 server and I use a GUI program on it via an X windows session.

A few nights ago I was just going to let things run so I SSH into the server from my Windows machine, start up the program, let it run then put my computer to sleep.

When I started up the computer in the morning I realized that I had lost the connection with the Linux server (to be expected if I put the computer to sleep, as the network card is going to go down as well) but my program had also been cut off when I put the computer to sleep. I did not think that through.

Is there any way to keep the GUI program running on the Linux server even if I want to put my Windows computer to sleep at night (the one I connect from)? Otherwise I need to leave my computer on continuously as well.

many thanks
 
Old 06-17-2020, 10:51 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,162

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
I use TigerVnc so it connects to a running session on the Linux box. However I have a monitor, keyboard and mouse on the Linux box. If the server is headless, it's trickier to set up but still doable.
 
Old 06-17-2020, 11:57 AM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
The nohup (no hang up) command will prevent the remote job from ending when the initiating connection ends.
 
2 members found this post helpful.
Old 06-17-2020, 02:38 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,020

Rep: Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630
https://unix.stackexchange.com/quest...econnect-later
 
Old 06-17-2020, 03:37 PM   #5
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 261
Blog Entries: 3

Rep: Reputation: 113Reputation: 113
What I normally do is:
  1. if I want to run a GUI session I just VNC to connect to the server. When I disconnect the VNC session it will still be running on the server and I can always reconnect to that session
  2. if I want an SSH session to stay alive, you can use the screen command. When I log in using SSH, I issue the screen command.

    It will start up with some information, then I can start anything on the terminal. Then I can disconnect from that running SSH session using <Ctrl-A> and then <d>. I can close the SSH session. When I restart a new SSH session, I can pick up the still running session with the command screen -r

To me it seems that your question is how to keep a SSH session alive, and I use the screen command daily for that. You can even have multiple SSH sessions running in the background in parallel without the need for any open SSH session.

You can do a lot more with the screen command, just check out the MAN page: https://linux.die.net/man/1/screen but this is the simple way I use it..

Last edited by Hermani; 06-17-2020 at 03:45 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting harddisk to sleep... and keeping it sleepy crispy_chunks Linux - Hardware 5 01-09-2009 02:33 AM
Waking my computer up after it goes to sleep Fosforo Ubuntu 4 01-20-2007 02:35 PM
Searching for Server (BOOTP/DHCP) <sleep> <sleep> .. .. Eileen Linux - Networking 12 10-21-2005 01:14 AM
disconnected when the computer goes to sleep (gentoo) miraclaire Linux - Networking 1 01-22-2004 08:44 AM
Linux server goes into sleep mode? medpa1 Linux - Networking 3 03-07-2002 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration