Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Last active January 15, 2025 09:49
Show Gist options
  • Save icaoberg/e509a4a4939f26e91216e868c3333659 to your computer and use it in GitHub Desktop.
Save icaoberg/e509a4a4939f26e91216e868c3333659 to your computer and use it in GitHub Desktop.
A better version of squeue (for me)
#!/bin/bash
# Alias: sq
# This alias is a shorthand for a customized display of job information using the 'squeue' command.
# Command:
# squeue -o "%.18i %.9P %.50j %.8u %.2t %.10M %.6D %R"
# Description of the 'squeue' options:
# - 'squeue': A command used to view information about jobs in the Slurm workload manager.
# - '-o': Specifies the format for displaying the output. The format string contains placeholders to control what information is shown and how it is formatted.
# Format placeholders in the alias:
# - '%.18i': Job ID, limited to 18 characters.
# - '%.9P': Partition name, limited to 9 characters.
# - '%.50j': Job name, limited to 50 characters.
# - '%.8u': User name, limited to 8 characters.
# - '%.2t': Job state, limited to 2 characters (e.g., R for running, PD for pending).
# - '%.10M': Time used by the job, limited to 10 characters (e.g., days-hours:minutes:seconds).
# - '%.6D': Number of nodes allocated to the job, limited to 6 characters.
# - '%R': Node list or reason for pending jobs.
# Usage:
# After defining this alias in your shell configuration file (e.g., .bashrc or .bash_profile),
# you can type 'sq' in the terminal to view a custom-formatted job list in Slurm.
# Example:
# If you type 'sq' in the terminal, you might see an output like this:
#
# JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
# 123456789 batch example_job_name_example_user R 00:01:23 1 compute-0-1
# Define the alias
alias sq='squeue -o "%.18i %.9P %.50j %.8u %.2t %.10M %.6D %R"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment