Score:0

Using a script for slurm

ua flag

I'm a beginner user on Ubuntu 20.04 LST. Down there where it is a script on python for slurm that I have been trying to work however it doesn't.

There is something wrong at three variables.

#! /bin/bash

ROOT_UID=0

#Run as root, of course. (this might not be necessary, because we have to run the script somehow with root anyway)
if [ "$UID" -ne "$ROOT_UID" ]
then
     echo "Must be root to run this script"
     exit "$E_NOTROOT"
fi

#test, arguments are down there for slurm.
if [ $# -eq 3 ]; then
slurmname=$1
accountname=$2
maxjobsnumbers=$3
          
       # to create just a slurm user on the default account
       sacctmgr create user -s "$slurmname"  "$accountname"
           
       # to setup job limit for a slurm user
       sacctmgr -i modify user "$slurmname" set "$maxjobsnumbers"
       
       # to show job limit
       sacctmgr show ass

       echo ""
       echo "The user has been setuped on Slurm"
       sacctmgr show user "$slurmname"
else
       echo  " this program needs 3 arguments you have given $# "
       echo  " you have to call the script $0 slurmname, accountname and maxjobsnumbers "
fi
exit 0

When i run the .sh file with the command, output is;

tonny (slurmname)

music (accountname)

1 (maxjobsnumbers)

 root@hn:/home/sysadmin1/Desktop# ./adduser_slurm.sh tonny music 1

 Need name of account to add user to.
 Nothing new added.
 Bad format on 1: End your option with an '=' sign
 Cluster    Account       User  Partition     Share   Priority 
 GrpJobs       GrpTRES GrpSubmit     GrpWall   GrpTRESMins 
 MaxJobs       MaxTRES MaxTRESPerNode MaxSubmit     MaxWall   
 MaxTRESMins                  QOS   Def QOS GrpTRESRunMin 
 ---------- ---------- ---------- ---------- --------- --------- 
 - ------- ------------- --------- ----------- ------------- ---- 
 --- ------------- -------------- --------- ----------- --------- 
 ---- -------------------- --------- ------------- 
 cluster       root                               1                                                                                                                                                             
 normal                         
 cluster       root       root                    1                                                                                                                                                             
 normal                         
 cluster      music                               1                                                                                                                                                             
 normal                         
 cluster      music       cta1                    1                                                                            
 3                                                                                
 normal                         
 cluster      music       cta2                    1                                                                            
 2                                                                                
 normal                         

  The user has been setuped on Slurm
  User   Def Acct     Admin 
  ---------- ---------- --------- 



                                                      

No new user who has been added.

I mean, how I can create a new user, how I can add the new user on slurm account, and how I can setup maxjob limits for the new user with this script on slurm?

waltinator avatar
it flag
Always paste your script into `https://shellcheck.net`, a syntax checker, or install `shellcheck` locally. Make using `shellcheck` part of your development process.
dreamer avatar
ua flag
$ shellcheck myscript No issues detected! shellcheck output
waltinator avatar
it flag
Read https://askubuntu.com/help/how-to-ask and https://askubuntu.com/help/formatting . Please [edit] your post to add new information, properly formatted. Information added via comments is hard for you to format, hard for us to read and ignored by future readers (who have better answers). Please click [edit] and add that vital information to your question so all the facts we need are in the question. Please don't use Add Comment, since that's our uplink to you. All facts about your system should go in the Question with [edit].
waltinator avatar
it flag
Read `man bash`. You can watch execution with `bash -x ./myscript`
cn flag
What does this error mean: `Bad format on 1: End your option with an '=' sign`. I found some documentation online. Your `create user` command doesn't look like [the examples](https://slurm.schedmd.com/sacctmgr.html#lbBR)
cn flag
This question isn't specifically about ubuntu. I'd suggest it gets moved to StackOverflow
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.