# SSH kills all background processes but I use OpenRC

## happysmash27

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?

----------

## pjp

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.

----------

## The Doctor

Bash doesn't support &! Replace with foo & disown instead.

----------

## szatox

How 'bout those options?

```
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.

----------

## happysmash27

 *The Doctor wrote:*   

> Bash doesn't support &! Replace with foo & disown instead.

 

I'm using ZSH, so it does support it. Thanks though!

----------

## The Doctor

Have you tried nohup foo & disown? &! should work as well since it is a shortcut. Zsh handles a disconnect a bit different than Bash.

----------

## happysmash27

 *szatox wrote:*   

> How 'bout those options?
> 
> ```
> screen ssh login@some.host
> 
> ...

 

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.

----------

## Tony0945

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

----------

## Hu

What daemon are you starting?  Normally, its init script should automatically background it in a way that preserves it past your disconnect.

----------

## szatox

Alright, I'm not quite sure what you're trying to do.

Can you describe your desired setup? Or maybe even draw it?

----------

