Parallel Document Conversion ODT > PDF Libreoffice

后端 未结 6 1581
别跟我提以往
别跟我提以往 2021-02-05 22:41

I am converting hundreds of ODT files to PDF files, and it takes a long time doing one after the other. I have a CPU with multiple cores. Is it possible to use bash or python to

6条回答
  •  温柔的废话
    2021-02-05 22:58

    Untested potentially valid:

    You /may/ be able to:

    • Divide up the files into a number of parallel batches in some equitable way, e.g. placing them all in folders;
    • Create a distinct local user account to handle each folder;
    • Run Libreoffice serially as each user

    e.g.

     for paralleluser in timlev1 timlev2 timlev3 timlev4 ; do
          su - $paralleluser -c \
             "for file in /var/spool/pdfbatches/$paralleluser ; do \
                libreoffice --headless --convert-to pdf $file ; done" 
     done
    

    By using su - you won't accidentally inherit any environment variables from your real session, so the parallel processes shouldn't interfere with one another (aside from competing for resources).

    Keep in mind, these are likely I/O-bound tasks, so running 1 per CPU core will probably not speed you up so very much.

提交回复
热议问题