Tmux for Long-Running Processes

lesson tools active tools/tmux-long-running-processes.md View on GitHub

Tmux for Long-Running Processes

Rule

Always use tmux (not shell tool) for processes exceeding 120-second shell timeout.

Context

When running commands that need more than 2 minutes to complete, such as benchmarks, optimization runs, builds, or data processing.

Detection

Observable signals that tmux is needed:

Common examples:

Pattern

Use tmux with proper verification:

# Start long-running process in tmux
tmux new-session -d -s mysession 'cd /path/to/project && command with args'

# Monitor progress periodically
tmux capture-pane -p -t mysession

# After completion, retrieve results
tmux capture-pane -p -t mysession
# Process results...

# Clean up when done
tmux kill-session -t mysession

Anti-pattern: Using shell tool for long processes

# Wrong: shell timeout kills process at 120s
poetry run python -m long_benchmark --train-size 20 ...
# Process starts, reaches 120s, gets killed

# Correct: tmux persists beyond timeout
tmux new-session 'poetry run python -m long_benchmark --train-size 20 ...'
# Process runs to completion (30-60 min)

Outcome

Following this pattern ensures:

Benefits:

Match Keywords

process killed at 120 seconds shell timeout exceeded tmux for long-running process process runs longer than 2 minutes 120-second shell timeout long-running command needs tmux