Writing single script with mutiple sbatch parts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing single script with mutiple sbatch parts
# 1  
Old 11-26-2018
Writing single script with mutiple sbatch parts

Hello,

I wrote several scripts that work with job arrays (sbatch) that look like this:


Code:
#!/bin/bash
#SBATCH --partition=carl.p
#SBATCH --ntasks=4
#SBATCH --time=0-10:00
#SBATCH --mem-per-cpu=48G
#SBATCH --job-name=basic_test
#SBATCH --mail-type=END,FAIL
#SBATCH --mail-user=
#SBATCH --array=1-48



These scripts all do different things and some need to be finished before other scripts can start.

I already figured out how to write a jobdependency script that times which scripts need to be started and which need to wait until specific scripts are finished. Now I want to know if it is possible to combine all those different scripts into one big script. I want to do this because I dont want to copy all the different scripts everytime i want to use them and I also want to use the same variables in the different scripts so that I only have to define them once. This is just to make everything more user friendly.

I wanted to do something like this



Code:
#!/bin/bash
#SBATCH --partition=carl.p
#SBATCH --ntasks=4
#SBATCH --time=0-10:00
#SBATCH --mem-per-cpu=48G
#SBATCH --job-name=basic_test
#SBATCH --mail-type=END,FAIL
#SBATCH --mail-user=
#SBATCH --array=1-12      



Here would be the first script that submits 12 jobs only containing the code up to the next SBATCH input...

CODE
CODE 
CODE
...




           #!/bin/bash
           #SBATCH --partition=carl.p
           #SBATCH --ntasks=4
           #SBATCH --time=0-10:00
           #SBATCH --mem-per-cpu=48G
           #SBATCH --job-name=basic_test
           #SBATCH --mail-type=END,FAIL
           #SBATCH --mail-user=
           #SBATCH --array=1-48           
           #SBATCH --dependency:afterok Job_id_of_first_script
  
            Here would be the second script which needs to run the 48 jobs from the second SBATCH input only once

            CODE
            CODE
            CODE
            ...

and so on.

These scripts should all work seperately so I dont want the first SBATCH to start a new SBATCH for the second job everytime. I have not tried anything to do this and I just wanted to know if this is at all possible.

Thanks in advance
# 2  
Old 11-27-2018
Moderator's Comments:
Mod Comment Thread reopened after message from idbemad explaining this is not a double post ...
This User Gave Thanks to Neo For This Post:
# 3  
Old 11-27-2018
Clarification

Some people might have missunderstood the previous part.

I'm trying to find out if there is a way to write several sbatch scripts into one file so that this one file includes the code for all the seperate scripts.

My idea was something like this:

Code:
#!/bin/bash


variable=whatever



#SBATCH ....
Code for first sbatch 

...
end of code for first sbatch

    #SBATCH ...
    Code for second sbatch
    ...

    end of code for second sbatch
    

           #SBATCH
           Code for third sbatch
           ...
           end of code for third sbatch


and all of this should be in one big executable file including all the code and the different parameters and dependencies for the seperate sbatches.

This way I could define all the variables once and use them in every script and can make sure that the right paths for the variables are set because they are created in the scripts and saved as a variable.

I hope this makes things clearer.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to ignore mutiple strings when using shell script?

Hi All, I am trying to use below syntax to find ignore multiple locations while searching for a file. find / -name "$serviceitem" ! -size 0 2>&1 |egrep -v "tmp|docker|WinSxS|Permission|HISTORY|alternatives|bearer11ssl|manifest" I tried to assign all the ignore strings to one variable... (2 Replies)
Discussion started by: sravani25
2 Replies

2. Shell Programming and Scripting

awk to remove mutiple values from specific pattern, leaving a single value

In the awk below I am trying to remove all instances after a ; (semi-colon) or , (comma) in the ANN= pattern. I am using gsub to substitute an empty string in these, so that ANN= is a single value (with only one value in it the one right after the ANN=). Thank you :). I have comented my awk and... (11 Replies)
Discussion started by: cmccabe
11 Replies

3. Shell Programming and Scripting

Convert mutiple spaces file to single tab

I have the following file I wanted to convert mutiple spaces to tab: I tried cat filename | tr ' ' '\t' or sed 's/ */ /' FILE but it looses the format 5557263102 5557263102 5552074858 5726310211 5557263102 5557263102 5557263103 5557263103 2142406768 ... (2 Replies)
Discussion started by: amir07
2 Replies

4. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

5. UNIX for Dummies Questions & Answers

awk script combining mutiple commands

Hi, I am pretty new to the unix community and have encountered a problem that I am trying to solve. I have 2 files one of which is called passwd file that looks like the following Sample Output daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh ... (1 Reply)
Discussion started by: raven905
1 Replies

6. Shell Programming and Scripting

Need a script to add mutiple printers in solaris box

Hi , i need to configure around 80 printers in a server. can someone please help me with the script. i have a file that has printer name and its ip. like. printer1 1.1.1.1 printer2 0.0.0.0 and so on.. can some one please help me to do it via script. i am using solaris 10 ... (0 Replies)
Discussion started by: chidori
0 Replies

7. Shell Programming and Scripting

Format Parts of Multiline Section to Single Line

Hello, I have an input file that I need formatted. I was hoping I could use bash to get this done. Title: Kitchen Blender Washer Dishes Title: Bathroom Toilet Sink Title: Bedroom Bed Desired output would be similar to Results("Blender","Washer","Dishes") (1 Reply)
Discussion started by: jl487
1 Replies

8. Shell Programming and Scripting

writing the content of two files to a single file horizontally

Hi all, assume that i am having two files file.1 and file.2 these are the contents of file.1 these are the contents of file.2 i want these two contents to be written in another single file like this. can you please post your suggestions. Thanks in advance, ... (3 Replies)
Discussion started by: anishkumarv
3 Replies

9. Shell Programming and Scripting

Display mutiple line in single line

Hi All, I had a file called Input.txt, i need to group up in a single line as 1=ttt and the no of lines may vary bewteen the 1=ttt cat Input.txt 1=ttt,2=xxxxxx, 3=4545 44545, 4=66667 7777, 5=77723 1=ttt, 2=xxxxxx, 3=34436 66 3545, 4=66666, 5=ffffff, 6=uuuuuuu 1=ttt, 2=xxxxxx,... (4 Replies)
Discussion started by: manosubsulo
4 Replies

10. IP Networking

Script to assign mutiple IP's to 1 nic

I need a script to assign multiple IP addresses to a single nic. The machine is running CentOS. Any help would be appreciated. (2 Replies)
Discussion started by: ron310
2 Replies
Login or Register to Ask a Question