forked from eegsynth/eegsynth
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparallel
More file actions
executable file
·40 lines (33 loc) · 968 Bytes
/
Copy pathparallel
File metadata and controls
executable file
·40 lines (33 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
#
# Bash script to execute multiple instances of a specific program in parallel.
#
# This script is inspired by http://stackoverflow.com/questions/356100/how-to-wait-in-bash-for-several-subprocesses-to-finish-and-return-exit-code-0
# and by http://www.gnu.org/software/parallel/
#
# Killing the child processes can be difficult if you only have the PID of the parent parallel script. Please see
# http://stackoverflow.com/questions/392022/best-way-to-kill-all-child-processes/33556110#33556110
OS=`uname -s`
MACHINE=`uname -m`
COMMAND=$1
ARGS=`echo $2 | tr ',' ' '`
if [ -z "$COMMAND" ] ; then
cat << EOF
Use as:
parallel <command> <arg1,arg2,arg3>
This will start in parallel
command arg1
command arg2
command arg3
EOF
exit
fi
if [ -z "$ARGS" ] ; then
$COMMAND
else
if [ $OS = Linux ] ; then
echo $ARGS | xargs -IARG -d " " -n 1 -P 16 $COMMAND ARG
elif [ $OS = Darwin ] ; then
echo $ARGS | xargs -IARG -n 1 -P 16 $COMMAND ARG
fi
fi