View previous topic :: View next topic |
Author |
Message |
happysmash27 Apprentice
Joined: 28 Mar 2016 Posts: 220
|
Posted: Wed Oct 11, 2017 1:44 am Post subject: SSH kills all background processes but I use OpenRC |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Wed Oct 11, 2017 3:13 am Post subject: |
|
|
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 |
|
|
The Doctor Moderator
Joined: 27 Jul 2010 Posts: 2678
|
Posted: Wed Oct 11, 2017 4:11 am Post subject: |
|
|
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 |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3135
|
Posted: Wed Oct 11, 2017 7:56 pm Post subject: |
|
|
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 |
|
|
happysmash27 Apprentice
Joined: 28 Mar 2016 Posts: 220
|
Posted: Wed Oct 11, 2017 11:42 pm Post subject: |
|
|
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 |
|
|
The Doctor Moderator
Joined: 27 Jul 2010 Posts: 2678
|
Posted: Wed Oct 11, 2017 11:52 pm Post subject: |
|
|
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 |
|
|
happysmash27 Apprentice
Joined: 28 Mar 2016 Posts: 220
|
Posted: Thu Oct 12, 2017 12:21 am Post subject: |
|
|
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 |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Thu Oct 12, 2017 12:44 am Post subject: |
|
|
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 |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21631
|
Posted: Thu Oct 12, 2017 1:15 am Post subject: |
|
|
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 |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3135
|
Posted: Thu Oct 12, 2017 8:18 pm Post subject: |
|
|
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 |
|
|
|