I'm compiling a huge list of commands (all doing the same thing) I want executed, but as it takes a long time to compile that list, I would like execution to begin before I'm done (execution of each command typically takes longer than creating another, so there's no real risk of the list running dry).
The normal way to execute a list of commands, is to write a shell script listing the commands, but when I start execution of a script I can't add to it anymore.
The way I've found so far is to put the commands in command.list
and having parallel --jobs 1 --line-buffer :::: command.list
, but as it involves using parallel
(I'm using GNU parallel, I don't know if it will work with the program in more-utils) for non-parallel execution of things, I think it's a bit of an abuse of parallel
.
Is there a simpler way of doing it? Something that tracks which commands have been executed in case I screw up something and the list does run out, would be nice.
sh ./command.list
orsh <(tail -n+1 -f command.list)
sh ./command.list
does not discover new commands added to the list. The solution withtail
seems to do what I want, but unlike the solution withparallel
it doesn't exit when the list is empty (I don't really know which I prefer).sh ./command.list
should discover new commands added to the list as long as they are added to the list beforesh
has reached the end of it. You could also just dosh <(command-that-generates-that-list)
or justcommand-that-generates-that-list | sh
if the commands do not read their stdin.