Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep processes open within zellij session after disconnecting from SSH ? #3531

Open
romaric-siri opened this issue Jul 30, 2024 · 10 comments · May be fixed by zellij-org/zellij-org.github.io#252

Comments

@romaric-siri
Copy link

Hello,

I wanted to know if thats a zellij bug or thats something I don't understand, here what I did :

  • I connect to my server using SSH
  • I attach my existing zellij session using : zellij a "main"
  • I start my process using ./server.sh or something like that
  • I detach the zellij session using CTRL+D
  • I disconnect from my server using "exit"

But : When I log back, the process has stopped automatically and zellij asks me to re run it

This is before I detach the session (the process I want to keep open)

azeazezae

This is after I reconnect and re-attach the zellij session, the process has stopped ...

after

Is it normal ? Is there a way to keep that process open within zellij even after I disconnect from SSH, and to have it back when I re-attach the session?

Thanks for your help.

@imsnif
Copy link
Member

imsnif commented Jul 30, 2024

It's very likely that something on the server is killing the detached Zellij process (eg. systemd is notorious for doing this to processes that are not owned by any connected user). I'd try looking in that direction.

@jwilger
Copy link

jwilger commented Aug 13, 2024

@romaric-siri I'm guessing your server is running systemd? By default, systemd kills all user processes on logout. This is a departure from the old initrc setups. It's nothing to do with zellij per se.

@wllenyj
Copy link

wllenyj commented Oct 18, 2024

Why the tmux can hold on to its process on the same Ubuntu?

I often use tmux as nohup to run some job to background. But zellij can't work to this case.

@romaric-siri
Copy link
Author

romaric-siri commented Oct 18, 2024

That's what i was wondering, I have no problem when running Screen for similar use case ...

@chubi-x
Copy link

chubi-x commented Oct 25, 2024

I'm wondering if there's any news with this as I have the same problem and it happens even when running locally. Whenever i resurrect a session my progress isn't actually saved since the process is not persisted as zellij just runs it again from the top.

adaschma added a commit to adaschma/zellij-org.github.io that referenced this issue Nov 12, 2024
@adaschma
Copy link

@chubi-x @wllenyj @romaric-siri I have written some documentation to help: https://github.com/adaschma/zellij-org.github.io/blob/systemd-integration/docs/src/integration.md#keep-session-running-after-logout-on-systemd

Please tell me, if it is clear and works for you or any suggested changes. I will then send a pull request to make it part of the official documentation.

@adaschma
Copy link

It has now been a week and I haven't heard from anybody. @chubi-x @wllenyj @romaric-siri did you have a chance to read it? Or do you still plan on doing so?

@chubi-x
Copy link

chubi-x commented Nov 21, 2024

Sorry for the late reply @adaschma. The suggested command didn't work for me on linux ubuntu 24.04. I had to use systemd-run instead of systemd-bin. Also i'm running zellij as the default shell for alacritty so I don't know how the suggested command will integrate with that since zellij is started by alacritty.

@adaschma
Copy link

Thanks @chubi-x for catching that. Don't know how I missed that. Fixed it. In alacritty.toml you can add something like:

[shell] program = "systemd-run" args = ["--scope", "--user", "zellij"]

@adaschma adaschma linked a pull request Nov 26, 2024 that will close this issue
@wllenyj
Copy link

wllenyj commented Dec 9, 2024

Sorry for late @adaschma, now I can't reproduce the problem anymore. I upgraded zell to 0.41.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants