Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SSH kills all background processes but I use OpenRC
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
happysmash27
Apprentice
Apprentice


Joined: 28 Mar 2016
Posts: 220

PostPosted: Wed Oct 11, 2017 1:44 am    Post subject: SSH kills all background processes but I use OpenRC Reply with quote

I'm trying to remotely enable a firewall while still enabling SSH, but I want my session to last long enough to allow the SSH port to be re-opened. Unfortunately, however, whatever I do, weather it be adding `&!` to the end of my command, using screen, using tmux, or starting a deamon which I know usually stays open in the background, any process I launch is killed as soon as I log out! All the answers I find for this question when searching online are only applicable to systemd systems or simply don't work. Does anyone know how I can stop my processes from being killed and start my firewall?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Wed Oct 11, 2017 3:13 am    Post subject: Reply with quote

For bash shells, do you have the environment variable TMOUT set anywhere?

I'm not sure what other shells might use.

Also, the ssh configuration may come into play. I use the defaults without having my tmux sessions closed, but TCPKeepAlive, ClientAliveInterval, & ClientAliveCountMax may be a factor.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2678

PostPosted: Wed Oct 11, 2017 4:11 am    Post subject: Reply with quote

Bash doesn't support &! Replace with foo & disown instead.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3135

PostPosted: Wed Oct 11, 2017 7:56 pm    Post subject: Reply with quote

How 'bout those options?
Code:
screen ssh login@some.host
screen -d -m ssh login@some.host
screen -D -m ssh login@some.host

Remember to detach screen (kbd hkeys: 'C-a d' or 'C-a C-d') before logging out. You don't want to log out from within screen, this session is meant to keep running after you leave.
Back to top
View user's profile Send private message
happysmash27
Apprentice
Apprentice


Joined: 28 Mar 2016
Posts: 220

PostPosted: Wed Oct 11, 2017 11:42 pm    Post subject: Reply with quote

The Doctor wrote:
Bash doesn't support &! Replace with foo & disown instead.


I'm using ZSH, so it does support it. Thanks though!
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2678

PostPosted: Wed Oct 11, 2017 11:52 pm    Post subject: Reply with quote

Have you tried nohup foo & disown? &! should work as well since it is a shortcut. Zsh handles a disconnect a bit different than Bash.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
happysmash27
Apprentice
Apprentice


Joined: 28 Mar 2016
Posts: 220

PostPosted: Thu Oct 12, 2017 12:21 am    Post subject: Reply with quote

szatox wrote:
How 'bout those options?
Code:
screen ssh login@some.host
screen -d -m ssh login@some.host
screen -D -m ssh login@some.host

Remember to detach screen (kbd hkeys: 'C-a d' or 'C-a C-d') before logging out. You don't want to log out from within screen, this session is meant to keep running after you leave.


But wouldn't my computer need to remain connected to the internet for that to work? My problem was originally that I thought SSH would be disconnected from the PC (though it turns out that turning on the firewall works fine with SSH if you use the home router guide), though now my main problem is that I can't have something connected to SSH all the time, and want to start a deamon.
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Thu Oct 12, 2017 12:44 am    Post subject: Reply with quote

atrun? You could set "at now+ 50" and log out. 50 seconds after you type the command, it will run in it's own shell. atrun is like a one time cron job. See man arun https://linux.die.net/man/8/atrun
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Thu Oct 12, 2017 1:15 am    Post subject: Reply with quote

What daemon are you starting? Normally, its init script should automatically background it in a way that preserves it past your disconnect.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3135

PostPosted: Thu Oct 12, 2017 8:18 pm    Post subject: Reply with quote

Alright, I'm not quite sure what you're trying to do.
Can you describe your desired setup? Or maybe even draw it?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum