Here's a preview from my zine, Bite Size Bash! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
get the zine!
read the transcript!
scripts can run many processes in parallel
python -m http.server &
curl localhost:8080
& starts python in the “background”, so it keeps running while curl runs
wait waits for all background processes to finish
command1 &
command2 &
wait
this waits for both command1 and command2 to finish
concurrency is easy* in bash
in other languages:
smiling stick figure with short curly hair, thinking: threads? how do I do that again?
in bash:
thing1 &
thing2 &
wait
* (if you keep it very simple)
background processes sometimes exit when you close your terminal
you can keep them running with nohup or by using tmux/screen.
$ nohup ./command &
panel 5:
person: jobs, fg, bg, and disown let you juggle many processes in the same terminal, but I almost always just use multiple terminals instead
panel 6:
jobs: list shell’s background processesdisown: like nohup, but after process has startedfg and bg: move process to foreground/background