How to start a program in ssh and keep it on after ssh ends

Moderators: odroid, mdrjr

How to start a program in ssh and keep it on after ssh ends

Unread postby jiffysound » Fri Dec 07, 2018 6:55 pm

I want to start a program, in this case Hexchat in a ssh session and keep it running when I close out of the ssh session. I got so far
Code: Select all
export DISPLAY=:0
then I run the command
Code: Select all
hexchat
It opens up the hexchat program but as soon as I close out of the ssh session, the hexchat program is killed. I want it to stay. What syntax would I need for this to work ?
jiffysound
 
Posts: 66
Joined: Wed Sep 07, 2016 9:49 pm
languages_spoken: english
ODROIDs: odroid c2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby Firestorm » Fri Dec 07, 2018 10:58 pm

Try ‘screen’
Firestorm
 
Posts: 31
Joined: Sun Apr 08, 2018 4:19 pm
languages_spoken: english
ODROIDs: ODROID C2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby rooted » Sat Dec 08, 2018 12:22 am

Run it with nohup

Code: Select all
nohup your_command &
User avatar
rooted
 
Posts: 5905
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english

Re: How to start a program in ssh and keep it on after ssh e

Unread postby mad_ady » Sat Dec 08, 2018 1:08 am

Or if you don't need X for other purposes, you can use xpra as a "screen for X"
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: How to start a program in ssh and keep it on after ssh e

Unread postby jiffysound » Sat Dec 08, 2018 10:11 am

rooted wrote:Run it with nohup

Code: Select all
nohup your_command &


Hey thanks! It worked :)
Code: Select all
ludafisk@odroid64:~$ export DISPLAY=:0 && nohup hexchat &
[1] 21845
ludafisk@odroid64:~$ nohup: ignoring input and appending output to 'nohup.out'
^C

And the Hexchat program wasn't removed, thank you.
jiffysound
 
Posts: 66
Joined: Wed Sep 07, 2016 9:49 pm
languages_spoken: english
ODROIDs: odroid c2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby jiffysound » Mon Dec 10, 2018 11:01 am

I am having a problem with nohup.out permission.
Code: Select all
ludafisk@odroid64:~$ export DISPLAY=:0 && nohup hexchat &
[1] 3836
ludafisk@odroid64:~$ nohup: failed to open 'nohup.out': Permission denied
nohup: failed to open '/home/ludafisk/nohup.out': Permission denied


Here is the permission for my home
Code: Select all
ludafisk@odroid64:~$ ls -l
-rw-r--r-- 1 root   root      62152 Jun 26  2017 list.txt
-rw-r--r-- 1 root   root      61963 Jun 26  2017 list1.txt
-rw-r--r-- 1 root   root          0 Nov 22 11:17 nohup.out

What syntax do I need to change it from root to user so that I can start Hexchat via SSH ?
Last edited by jiffysound on Mon Dec 10, 2018 11:35 am, edited 1 time in total.
jiffysound
 
Posts: 66
Joined: Wed Sep 07, 2016 9:49 pm
languages_spoken: english
ODROIDs: odroid c2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby rooted » Mon Dec 10, 2018 11:21 am

jiffysound wrote:I am having a problem with nohup.out permission.
Code: Select all
ludafisk@odroid64:~$ export DISPLAY=:0 && nohup hexchat &
[1] 3836
ludafisk@odroid64:~$ nohup: failed to open 'nohup.out': Permission denied
nohup: failed to open '/home/ludafisk/nohup.out': Permission denied


Here is the permission for my home
Code: Select all
ls -l  -rw-r--r-- 1 root   root          0 Nov 22 11:17 nohup.out

What syntax do I need to change it from root to user so that I can start Hexchat via SSH ?
Code: Select all
 sudo chown ludafisk:ludafisk /home/ludafisk/nohup.out
User avatar
rooted
 
Posts: 5905
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english

Re: How to start a program in ssh and keep it on after ssh e

Unread postby jiffysound » Mon Dec 10, 2018 11:38 am

Thank you, worked like a charm :)
jiffysound
 
Posts: 66
Joined: Wed Sep 07, 2016 9:49 pm
languages_spoken: english
ODROIDs: odroid c2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby rooted » Mon Dec 10, 2018 12:20 pm

You're welcome.

If you have some free time you may want to read some of the general commands you can use on a Linux system, I like the layout of this site:

https://www.tecmint.com/linux-commands-cheat-sheet/
User avatar
rooted
 
Posts: 5905
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english

Re: How to start a program in ssh and keep it on after ssh e

Unread postby jiffysound » Tue Dec 11, 2018 10:45 am

rooted wrote:You're welcome.

If you have some free time you may want to read some of the general commands you can use on a Linux system, I like the layout of this site:

https://www.tecmint.com/linux-commands-cheat-sheet/


Oh neat-o, I've searched for such guides all around, but haven't really stuck with one because they always seemed to lack something, you can't imagine how many .txt files and save-page-as directories I have saved up in my Ubuntu-How-To folder. I bookmarked it and placed it on top, we shall see if it holds the spot :)
jiffysound
 
Posts: 66
Joined: Wed Sep 07, 2016 9:49 pm
languages_spoken: english
ODROIDs: odroid c2

Re: How to start a program in ssh and keep it on after ssh e

Unread postby mad_ady » Tue Dec 11, 2018 1:33 pm

Maybe in the (not-so-distant) future there will be an ai for linux where you can ask "Hey Tux, how do I scan for all open ports on a system?" and it replies with the correct nmap command, or better yet, runs it for you. I'm sure new users would be delighted, but that would make us old-timer geeks obsolete...
"Listen here, nephew. Back in my day we used to type commands into the computer with a keyboard. And half of them wouldn't work. And we called that fun".
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: How to start a program in ssh and keep it on after ssh e

Unread postby rooted » Tue Dec 11, 2018 2:17 pm

Hey Google, scan network...

Scanning network...

Oh my, your back door is open :blush:
User avatar
rooted
 
Posts: 5905
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english


Return to Ubuntu

Who is online

Users browsing this forum: No registered users and 3 guests