Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Gauchard
par
Commits
89bbe630
Commit
89bbe630
authored
Jul 27, 2021
by
David Gauchard
Browse files
initial commit
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
par
0 → 100755
View file @
89bbe630
#!/bin/bash
time_limit
=
3600s
set
-e
help
()
{
cat
<<
EOF
Syntax:
$1
[-t timelimit]
Start local executables concurrently,
limited by the number of cores reported by 'nproc' (
$(
nproc
)
on this host).
Options:
-t timelimit (default:
${
time_limit
}
)
EOF
exit
1
}
while
[
!
-z
"
$1
"
]
;
do
case
"
$1
"
in
-t
)
time_limit
=
"
$2
"
;
shift
;;
-h
)
help
"
$0
"
;;
*
)
echo
"argument
$1
not understood"
;
help
"
$0
"
;
exit
1
;;
esac
shift
done
ncpu
=
$(
nproc
)
pids
=
.pid
mkdir
-p
${
pids
}
rm
-f
${
pids
}
/
*
for
exec
in
*
;
do
# must be executable
[
-x
${
exec
}
]
||
continue
# log file must not already exist
[
-r
${
exec
}
-log
.txt
]
&&
{
echo
"
${
exec
}
: logfile already exists"
;
continue
;
}
while
true
;
do
ucpu
=
$(
ls
${
pids
}
|
wc
-l
)
if
[
${
ucpu
}
=
${
ncpu
}
]
;
then
echo
"(all cpu used)"
sleep
1
else
echo
"start '
${
exec
}
'"
(
set
+e
;
\t
ime
timeout
${
time_limit
}
./
${
exec
}
>
&
${
exec
}
-log
.txt &
pid
=
$!
;
echo
${
exec
}
>
${
pids
}
/
${
pid
}
;
wait
${
pid
}
;
rm
-f
${
pids
}
/
${
pid
}
;
)
&
break
fi
done
done
echo
""
echo
"all started"
while
true
;
do
ucpu
=
$(
ls
${
pids
}
|
wc
-l
)
if
[
${
ucpu
}
=
0
]
;
then
echo
"all finished"
break
fi
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment