uabrc / devops-docs

https://docs.rc.uab.edu/devops-docs/
Apache License 2.0
1 stars 5 forks source link

Script to Add Missing Cheaha User Accounts #50

Open Premas opened 2 months ago

Premas commented 2 months ago

If Cheaha user accounts aren't added correctly, it can lead to various issues for those users. When launching an HPC desktop job, users may encounter an internal server error and Permission denied errors. Also, using srun may result in an invalid account partition error. These errors occur despite the successful creation of the user account.

Reference issue: RITM0702342

To add a missing Cheaha user account, you can execute the following script. We recommend adding this to your $HOME/.bashrc to have quick access to the function.

function slurm-add-account() {
    users=("${@:1}")

    for user in "${users[@]}"; do
      echo "$user"
      /cm/shared/apps/slurm/current/bin/sacctmgr --immediate add Account $user
      /cm/shared/apps/slurm/current/bin/sacctmgr --immediate add User Accounts=$user $user
    done

    for user in "${users[@]}"; do
      sacctmgr show Account $user
      sacctmgr show user $user
    done
}

To utilize this function, slurm-add-account, you simply need to input your username after the command. You can also add multiple usernames separated by spaces. slurm-add-account user1 user2 user3