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


#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" ]
     echo "Must be root to run this script"
     exit "$E_NOTROOT"

#test, arguments are down there for slurm.
if [ $# -eq 3 ]; then
       # 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"
       echo  " this program needs 3 arguments you have given $# "
       echo  " you have to call the script $0 slurmname, accountname and maxjobsnumbers "
exit 0

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

tonny (slurmname)

music (accountname)

1 (maxjobsnumbers)

 root@hn:/home/sysadmin1/Desktop# ./ 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                                                                                                                                                             
 cluster       root       root                    1                                                                                                                                                             
 cluster      music                               1                                                                                                                                                             
 cluster      music       cta1                    1                                                                            
 cluster      music       cta2                    1                                                                            

  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 ``, 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 and . 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](
cn flag
This question isn't specifically about ubuntu. I'd suggest it gets moved to StackOverflow

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.