Skip to content

Instantly share code, notes, and snippets.

@wallyqs
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallyqs/11141778 to your computer and use it in GitHub Desktop.
Save wallyqs/11141778 to your computer and use it in GitHub Desktop.
#+TITLE: Running scripts in parallel
In the following example, the following 3 scripts should be run in parallel
with all output being flushed to the screen.
- Count some numbers with bash
#+name: bash_counter
#+begin_src sh :shebang #!/bin/bash
echo '' > out.log
for i in `seq 1 5`; do
echo "Writing! $i"
echo "hello $i" >> out.log
sleep $(($RANDOM % 5))
done
#+end_src
- Count some numbers with ruby
#+name: ruby_counter
#+begin_src ruby :shebang #!/usr/bin/ruby
$stdout.sync = true
sleep 0.2
10.times do |n|
puts "And now writing! #{n}"
File.open("out.log", "a") {|f| f.puts "Hello again #{n}" }
sleep rand.round(2)
end
#+end_src
- Print some numbers with python
#+name: python_counter
#+begin_src python :shebang #!/usr/bin/python
for i in range(0,3):
print i
#+end_src
- Block that should not be run
#+begin_src js
{
"hello": "world"
}
#+end_src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment