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: .. code-block:: bash tmux new -s computation The session name should describe the project or experiment. Examples: .. code-block:: text computation affine_rack classification homology experiment_01 Running a Computation --------------------- After entering the session, start the computation: .. code-block:: bash ~/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: .. code-block:: text Ctrl+b d The computation continues running in the background. Listing Sessions ---------------- Show all sessions: .. code-block:: bash tmux ls Example output: .. code-block:: text computation: 1 windows experiment_01: 1 windows Reattaching to a Session ------------------------ Reconnect to a running session: .. code-block:: bash 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: .. code-block:: bash tmux kill-session -t computation Use this command to clean up unused sessions and free resources. Recommended Workflow -------------------- A typical workflow is: 1. Connect to the server. 2. Create a tmux session. 3. Launch the computation. 4. Detach from the session. 5. Disconnect from the server. 6. Reconnect later. 7. Attach to the session. 8. Inspect the results. 9. Terminate the session when finished. Example ------- Create a session: .. code-block:: bash tmux new -s affine_rack Run GAP: .. code-block:: bash ~/gap-4.15.1/gap -m 120000m ~/AFFINERACK/main.g Detach: .. code-block:: text Ctrl+b d Reconnect later: .. code-block:: bash tmux attach -t affine_rack Terminate when finished: .. code-block:: bash tmux kill-session -t affine_rack