1.关于slurm系统
- 指定节点提任务 :
#SBATCH --nodelist=c1405
- 杀残余进程
killall -9 vasp_std killall -9 vasp_gam
2. slurm系统的sq命令
#!/bin/bash
# A simple wrapper for squeue, requires bash 4.0+
# by Junhao Li@TCB
USAGE()
{
echo
echo "available arguments: "
echo " -h | --help print the help information"
echo " -P | --show_partition number (optional, default is 10)"
echo " -j | --job_length number (optional, default is 20)"
echo " -p | --workidng_dir number (optional, default is a full path)"
echo " -a | --show_account number (optional, default is 15)"
echo " -A | --tcb_users"
echo " * other arguments pass to squeue"
echo
}
resize >& /dev/null
[[ -z $1 ]] && squeue -u $USER -o ' %10i %15a %20j %8u %3t %10M %10l %4D%5C %20V %Z' && exit 0
squeueArgs=()
TCBUserList="lilu,user2,user3,user4" # replace the username here
while [[ $# -gt 0 ]]; do
case $1 in
-P | --show_partition)
showPartition="%10P"
[[ "$2" -gt 0 ]] && showPartition="%${2}P" && shift 2 || shift 1
;;
-U | --User_list) #user1,user2,.. or user1
if [[ -z $showTCBUsers ]]; then
if [[ "$2" -gt 0 ]]; then
userList="-u ${2}"
shift 2
else
echo "Warning: please give user after -u"
shift 1
fi
else
echo "-u could not be used with -A!"
exit 1
fi
;;
-j | --job_length)
[[ "$2" -gt 0 ]] && jobLength="%${2}j" || echo "Warning: please give number after -j"
shift 2
;;
-p | -wd | --working_dir)
showWorkingDir="%Z"
[[ "$2" -gt 0 ]] && showWorkingDir="%${2}Z" && shift 2 || shift 1
;;
-a | --show_account)
showAccount="%15a"
[[ "$2" -gt 0 ]] && showAccount="%${2}a" && shift 2 || shift 1
;;
-A | --tcb_users)
if [[ ! -z userList ]]; then
showTCBUsers="-u $TCBUserList"
shift 1
else
echo "-A could not be used with -u!"
exit 1
fi
;;
-s | --star | --start)
showStartTime="--start"
shift 1
;;
-aAp | -apA | -Aap | -Apa | -paA | -pAa)
showAccount="%15a"
showTCBUsers="-u $TCBUserList"
showWorkingDir="%Z"
shift 1
;;
-h | --help)
USAGE
exit 0
;;
*) # Other argurement pass to squeue!
squeueArgs=(${squeueArgs[*]} $1)
shift 1
;;
esac
done
[[ -z $jobLength ]] && jobLength="%20j"
#if [[ -z $userList ]] && [[ -z $showTCBUsers ]]; then
# userToShow="-u $USER"
#elif [[ ! -z $userList ]]; then
# userToShow=$userList
#elif [[ ! -z $showTCBUsers ]]; then
# userToShow=$showTCBUsers
#fi
format=$(echo " %10i $showPartition $showAccount $jobLength %8u %3t %10M %10l %4D%5C %20V $showWorkingDir")
squeue $userToShow -o "$format" $showStartTime ${squeueArgs[@]}
3. array 任务 限制同时运行的任务总数
#SBATCH --array=1-100%10
1-100
指定了任务数组的范围,即从 1 到 100 的任务。
%10
限制了同时运行的任务数为 10
–array的数字范围只能在0-1001 ,1001是最大值
–array是重复提交固定次数,运行标头下面的内容,然后可以做一些限制
#!/bin/sh
#SBATCH --job-name=scf
#SBATCH --output=log.out.%A_%a
#SBATCH --error=log.err.%A_%a
#SBATCH --partition=intel6240r_192
#SBATCH --nodes=1
#SBATCH --ntasks=48
#SBATCH --ntasks-per-node=48
#SBATCH --array=0-1000%15
#SBATCH --cpus-per-task=1
#SBATCH --exclusive
dir=$((SLURM_ARRAY_TASK_ID + 1000))
cd $dir || { echo "Failed to enter directory $dir"; exit 1; }
source /work/env/intel2018
srun hostname | sort | uniq >> /tmp/nodefile.$$
NP=`srun hostname | wc -l`
mpirun -genv I_MPI_FABRICS shm:tcp -machinefile /tmp/nodefile.$$ -n $NP /work/software/vasp.6.1.0/vasp_std > vasp.log 2>&1
#mpirun -genv I_MPI_FABRICS shm:ofa -machinefile /tmp/nodefile.$$ -n $NP /work/software/vasp.6.1.0/vasp_std > vasp.log 2>&1
rm -rf /tmp/nodefile.$$
4. 给每个文件分配一个文件夹
#!/bin/bash
# 初始化计数器
counter=0
# 获取当前目录下的所有文件
for file in *; do
# 检查是否是文件(排除目录)
if [ -f "$file" ]; then
# 使用计数器作为文件夹名
foldername="$counter"
# 创建文件夹,以计数器命名
mkdir -p "$foldername"
# 移动文件到对应的文件夹
mv "$file" "$foldername/"
# 递增计数器
counter=$((counter + 1))
fi
done
转载请注明来源 有问题可通过github提交issue