Running croc in the background so it keeps serving the file after you disconnect from your SSH session is a great idea — and there are a few ways to do it on Linux. Let’s go with some simple and reliable approaches:
Option 1: Using nohup (No Hangup)nohup prevents the command from being stopped when the SSH session ends.
nohup croc send directory.tar.gz.gpg > croc.log 2>&1 &
nohupkeeps the process running even after you log out.> croc.log 2>&1redirects output and errors to a file calledcroc.log.&puts the process in the background.
You can safely close your SSH session, and the file will still be available.
To check the progress or output:
tail -f croc.log
Option 2: Using screen (Persistent Sessions)
If screen isn’t installed, install it first:
sudo pacman -S screen
Then, start a screen session:
screen -S croc-session
Run your croc command inside the screen session:
croc send directory.tar.gz.gpg
To detach from the screen session without stopping the process:
- Press
Ctrl + A, thenD.
You can now log out safely. To resume the session later:
screen -r croc-session
Option 3: Using tmux (Another Terminal Multiplexer)
If you prefer tmux over screen:
sudo pacman -S tmux
Start a tmux session:
tmux new -s croc-session
Run your command:
croc send directory.tar.gz.gpg
Detach from tmux with Ctrl + B, then D.
To resume:
tmux attach -t croc-session
Option 4: Using disown (After Starting a Process)
If you already ran croc without thinking about backgrounding it, you can suspend it and disown it afterward.
Pause the process:
PressCtrl + Z.Move it to the background:
bg
- Disown it so it’s not tied to your session:
disown
Quick Recommendation:
- If this is a one-off and you don’t need to revisit the session: use
nohup. - If you might want to check the progress later: use
screenortmux.