Bash script, how to do two jobs at the same time

195 Views Asked by At

I'm writing a script for a usb dumper that detects devices and copy its contents to a location of my choice. I want to make a zip of the original directory but I don't want the scrip to stop detecting new devices while its zipping the file.

I have a while loop that uses a function to read the content of ubuntu's /media/user/* folder and I use gcp to copy the contents of the new Devices.

What command can I place so that the script doesn't stop the detection of devices just to zip the file?

Thanks for the help

1

There are 1 best solutions below

0
On

You can run anything in a subshell in the background with the & operator, such as

zip foo.zip bar baz qux &

That way, the zip process will run in the background while your loop continues.