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
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 <(tail -n+1 -f command.list)
sh ./command.listdoes not discover new commands added to the list. The solution with
tailseems to do what I want, but unlike the solution with
parallelit doesn't exit when the list is empty (I don't really know which I prefer).
sh ./command.listshould discover new commands added to the list as long as they are added to the list before
shhas reached the end of it. You could also just do
sh <(command-that-generates-that-list)or just
command-that-generates-that-list | shif the commands do not read their stdin.