Как отменить задания в Slurm с большим идентификатором задания (номером задания) чем определенное число?

Пожалуйста, используйте dateext . Вот примечания из man-страницы для logrotate:

 dateext
              Archive  old versions of log files adding a date extension like YYYYMMDD instead of simply adding a number. The extension may be
              configured using the dateformat and dateyesterday options.
2
18.02.2018, 00:00
2 ответа

Debe usar squeuepara obtener una lista de todos los trabajos que le pertenecen, luego recorrer esa lista y cancelar cada trabajo que coincida con su criterio (ID de trabajo mayor que X )con scancel.

squeuetiene opciones de salida muy flexibles, con su opción -otambién conocida como --formatpuede decirle que imprima exactamente lo que desea. En este caso, solo queremos el número de trabajo. Según man squeue, eso es %ien la cadena de formato:

%i Job or job step id.

In the case of job arrays, the job ID format will be of the form "_". By default, the job array index field size will be limited to 64 bytes. Use the environment variable SLURM_BITSTR_LEN to specify larger field sizes. (Valid for jobs and job steps) In the case of heterogeneous job allocations, the job ID format will be of the form "#+#" where the first number is the "heterogeneous job leader" and the second number the zero origin offset for each component of the job.

El siguiente script sh usa eso:

#!/bin/sh

if [ -z "$1" ] ; then
    echo "Minimum Job Number argument is required.  Run as '$0 jobnum'"
    exit 1
fi

minjobnum="$1"

myself="$(id -u -n)"

for j in $(squeue --user="$myself" --noheader --format='%i') ; do
  if [ "$j" -gt "$minjobnum" ] ; then
    scancel "$j"
  fi
done

Guárdelo como, por ejemplo, cancel-jobs.sh, hágalo ejecutable con chmod +x cancel-jobs.shy ejecútelo como ./cancel-jobs.sh 50000para cancelar todos sus trabajos con identificadores de trabajo superiores a 50,000.

Si desea cancelar números de trabajo mayores o iguales al número de trabajo mínimo, cambie el -gta -ge.


Una optimización menor es no cancelar cada trabajo individualmente, sino crear una lista de números de trabajo coincidentes y luego cancelarlos todos con una invocación de scancel.

Por ejemplo, usar una matriz bash para contener los números de trabajo:

#!/bin/bash

declare -a jobs=()

if [ -z "$1" ] ; then
    echo "Minimum Job Number argument is required.  Run as '$0 jobnum'"
    exit 1
fi

minjobnum="$1"

myself="$(id -u -n)"

for j in $(squeue --user="$myself" --noheader --format='%i') ; do
  if [ "$j" -gt "$minjobnum" ] ; then
    jobs+=($j)
  fi
done

scancel "${jobs[@]}"

Esto hace lo mismo que el primer script, pero un poco más eficiente.

3
27.01.2020, 22:03

Это не совсем ответ на то, как отменить задания, превышающие заданное число, но это сработает для проблемы, которую @mona -jalilvand пытался решить :отменить задания в диапазоне, как описано здесь

scancel  {1000..1050}

Гораздо проще, чем писать скрипты на bash... Мне это помогло.

12
27.01.2020, 22:03

Теги

Похожие вопросы