Run several jobs parallelly and Efficiently

后端 未结 3 1326
一整个雨季
一整个雨季 2020-11-30 14:28

OS: Cent-OS

I have some 30,000 jobs(or Scripts) to run. Each job takes 3-5 Min. I have 48 CPUs(nproc = 48). I can use 40 CPUs to run

3条回答
  •  忘掉有多难
    2020-11-30 15:15

    As Mark Setchell says: GNU Parallel.

    find scripts/ -type f | parallel
    

    If you insists on keeping 8 CPUs free:

    find scripts/ -type f | parallel -j-8
    

    But usually it is more efficient simply to use nice as that will give you all 48 cores when no one else needs them:

    find scripts/ -type f | nice -n 15 parallel
    

    To learn more:

    • Watch the intro video for a quick introduction: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
    • Walk through the tutorial (man parallel_tutorial). You command line with love you for it.

提交回复
热议问题