Using tmux for Long-Running Computations

Introduction

Scientific computations often run for hours or days.

Closing an SSH connection normally terminates the running process.

The recommended solution is to execute computations inside a tmux session.

A tmux session continues running even after disconnecting from the server.

Creating a Session

Create a new session:

tmux new -s computation

The session name should describe the project or experiment.

Examples:

computation
affine_rack
classification
homology
experiment_01

Running a Computation

After entering the session, start the computation:

~/gap-4.15.1/gap -m 120000m ~/PROJECTS/computation.g

The process continues running inside the tmux session.

Detaching from the Session

To leave the session without terminating the computation:

Press:

Ctrl+b d

The computation continues running in the background.

Listing Sessions

Show all sessions:

tmux ls

Example output:

computation: 1 windows
experiment_01: 1 windows

Reattaching to a Session

Reconnect to a running session:

tmux attach -t computation

This is the most frequently used command.

It allows monitoring the progress of long computations after logging back into the server.

Monitoring a Running Computation

After attaching, inspect:

  • Program output.

  • Log messages.

  • Error messages.

  • Progress indicators.

The computation continues exactly where it was left.

Terminating a Session

When the computation has finished and the session is no longer needed:

tmux kill-session -t computation

Use this command to clean up unused sessions and free resources.

Example

Create a session:

tmux new -s affine_rack

Run GAP:

~/gap-4.15.1/gap -m 120000m ~/AFFINERACK/main.g

Detach:

Ctrl+b d

Reconnect later:

tmux attach -t affine_rack

Terminate when finished:

tmux kill-session -t affine_rack