Timeline for Four tasks in parallel... how do I do that?
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 23, 2012 at 14:01 | history | edited | jw013 | CC BY-SA 3.0 | added 1 characters in body |
| Apr 2, 2012 at 17:43 | comment | added | jw013 | @DigitalRobot You can try it for yourself but the xargs man page seems to imply it will try to keep 4 processes running at all times. | |
| Apr 2, 2012 at 13:39 | comment | added | Duck | @jw013 - just one question: this answer you posted will just fire another 4 processes when all the original processes are done or will one new process be fired for each one that is done? | |
| Apr 2, 2012 at 9:36 | comment | added | Eugene S | Great! Thank you for your detailed explanation! | |
| Apr 1, 2012 at 18:23 | comment | added | jw013 | @EugeneS It's for maximum correctness and robustness. File names are not lines, and ls cannot be used to parse filenames portably and safely. The only safe characters to use to delimit file names are \0 and /, since every other character, including \n, can be part of the file name itself. The printf uses \0 to delimit file names, and the -0 informs xargs of this. The -I{} tells xargs to replace {} with the argument. | |
| Apr 1, 2012 at 13:47 | vote | accept | Duck | ||
| Apr 1, 2012 at 11:12 | comment | added | Eugene S | Sorry for not being precise. I was specifically interested why did you use printf function here rather than just regular ls .. | grep .. *.png? Also I was interested in the xargs parameters you used (-0 and -I{}). Thanks! | |
| Apr 1, 2012 at 10:05 | comment | added | jw013 | @EugeneS Could you be a bit more specific about what part? The printf collects all png files and passes them via a pipe to xargs, which collects arguments from standard input and combines them into arguments for the pngout command the OP wanted to run. The key option is -P 4, which tells xargs to use up to 4 concurrent commands. | |
| Apr 1, 2012 at 7:25 | comment | added | Eugene S | Could you please explain the proposed command? Thanks! | |
| Apr 1, 2012 at 4:41 | comment | added | wnoise | There are also "gnu parallel" and "xjobs" designed for this case. It's mostly a matter of taste which you prefer. | |
| Mar 31, 2012 at 4:11 | history | edited | jw013 | CC BY-SA 3.0 | forgot `-0` |
| Mar 31, 2012 at 4:05 | history | answered | jw013 | CC BY-SA 3.0 |