Bash Script -- run two processes at once?
I think this might be forking but I read the wiki and it says a fork is a copy of the parent, which isn't really what I want...
Basically I want two chunks of code running at the same time. I'm sure it's something really simple -- eg kind of like how there's process1 && process2. Or even better would be the ability to directly share variables in the same bash script -- #!/bin/bash chunk1{ } chunk 2{ } Either way works. |
Something like this?
Code:
#!/bin/bash 0 100 99 1 98 2 3 97 4 96 5 95 94 6 93 7 92 8 91 9 |
Yeah, this is what I was looking for. & just puts a process in the background (forgot all about that trick). Is this the same thing as forking or different?
It's weird though I had this bash script and arranged the code in the two functions. I have some image processes running in f() and when I run f& (eg f & g) I get these png errors. But if I run f (eg g & f) it doesn't error. Why would some programs need to be ran "directly"? Why cant they be put in the background? edit -- Hm for some reason it works now. I never touched the code. Weird. Thanks for the info that was exactly what I was looking for. |
All times are GMT -5. The time now is 05:36 PM. |