I am running a command using sbatch for a tool on the server, that takes a lot of space. The command uses some directories (some files) from a main directory(tq_first) in a for loop. I was wondering if there was a way to delete the directories once it's iterated in the loop and completely executed? will the remove command work there without interfering with the loop?
For e.g. for this loop
set -eu
export PATH=/home/bin:${PATH}
reference_dir=/mnt/scratchb/REF
for fastq_dir in fastq_first/*; do
barcode=`basename ${fastq_dir}`
cmd="cellranger count \
--id=${barcode} \
--fastqs= ${fastq_dir} \
--sample=${barcode} \
--transcriptome=${reference_dir} \
--localcores=32 \
--localmem=92"
sbatch --nodes=1 \
--cpus-per-task=32 \
--mem=96G \
--time=2880 \
-o cellranger_count.%j.out \
-e cellranger_count.%j.err \
-J cellranger_count <<EOF
cmd="rm -r $fastq_dir"
#!/bin/bash
echo "Start Cell Ranger count "`date`
echo ${cmd}
eval ${cmd}
echo "Done "`date`
cellranger count --version
EOF
done
#!/bin/bash) needs to be the first line of your file, you can't have it in the middle like that. Yes, you can absolutely delete the directory after running the command, but we need to see the actual script you use to be able to help you with it, one that shows us when you execute the command.forloop and the#!/bin/bashis ignored as a comment. Please show us your actual script, including the part where you execute$sbatchso we can understand what you are doing.