On Linux does the remove command rm run in the background

0 votes

I am trying to run my test cases which are nearly 40k with below scripts.

Just showing some part of script -

#!/bin/bash
# RUN script



echo "please run with: nice nohup ./run_script"

# working directory where script is stored
WORKING_DIR=$(pwd)

# temp directory to build and run the cmake ctest
BUILD_DIR=${BUILD_DIR:-/localtemp/build}

# clean and make build directory
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
mkdir -p $BUILD_DIR/../result

cmake -G Ninja

ninja test

Note: I am using parallel threading with 6 cores to run my test cases .

In first attempt all are passing which is true as I fixed all the bugs in my test cases.

But some time If I want to re-run same script freshly, then I am getting the error in running some test cases out of 40k. But If I run that failing test cases separately(one by one) then they are passing perfectly.

So I assumed that rm -rf is taking some time to delete that old binary and symbols of all cases (40 GB files). so I need to wait for complete deletion and then run my script once again . So should I add some delay after rm -rf command in my script .

I read somewhere that rm -rf will return the status once it finishes the work .Then only next command executes. But my scnerio looks like showing that rm -rf is running in background.
Means I should not start new run immediately when I stopped the earlier run . I need to give some time to delete the old output from earlier run using rm -rf command in script (delay introduction) and run my below ninja command after that. Is that true?

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
752 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
It's a little more complicated than that, to be sure. The command rm will not run in the background. What is certain is that the deletion is carried out logically (i.e., objects are removed from the user's perspective); this means that on some operating systems, the low-level deletion may be carried out in the kernel even if the command has finished (the kernel then really clean some internal structures behind your back). However, this should not generally cause any issues with your script. Your issue is mostly certainly elsewhere.

It's possible that some processes keep files even if they appear to be erased... As a result, the disc may not be freed as expected. You'll have to wait for those processes to finish before the kernel cleans the files properly.
answered Apr 27, 2022 by Edureka
• 13,690 points

edited Mar 5

Related Questions In Linux Administration

0 votes
0 answers
0 votes
1 answer

What is the linux command to find Memory and CPU usage in percent for last 30 days?

Try the following: Cat proc/meminfo top top -i less /proc/memin ...READ MORE

answered Oct 14, 2020 in Linux Administration by Kim
2,753 views
0 votes
1 answer

How to run one command inside another command in Linux?

Hi@akhtar, You can run multiple commands in your ...READ MORE

answered Oct 15, 2020 in Linux Administration by MD
• 95,460 points
3,166 views
0 votes
0 answers

What does the $ mean in Linux?

I have to explain what the code ...READ MORE

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
954 views
0 votes
0 answers

An alternative in php to the xxd command in linux

I need to convert the bin file ...READ MORE

Apr 13, 2022 in Linux Administration by Aditya
• 7,680 points
1,129 views
0 votes
0 answers

What exactly does the Unix `bash` command do when run without options?

When you type bash into the terminal ...READ MORE

Apr 14, 2022 in Linux Administration by Soham
• 9,710 points
493 views
0 votes
0 answers

How does the wc -c in linux work?

Why the number of characters is 4? echo ...READ MORE

Apr 14, 2022 in Linux Administration by Rahul
• 9,680 points
1,395 views
0 votes
0 answers

What is the difference between ''find .'' and ''find /'' on linux command

I am solving overthewire bandit. I looked ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
506 views
0 votes
0 answers

What does "&" at the end of a linux command mean?

I am a system administrator and I ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
684 views
0 votes
0 answers

How can I convert a series of images to a PDF from the command line on linux?

I have a scanning server I wrote ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
792 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP