inotifywait triggering event twice while converting docx to PDF

Jatin Dhoot

I have shell script with inotifwait set up as under:

inotifywait -r  -e close_write,moved_to  -m "<path>/upload" --format '%f##@@##%e##@@##%w'

There are some docx files residing in watched directory and some script converts docx to PDF via below command:

soffice --headless --convert-to pdf:writer_pdf_Export <path>/upload/somedoc.docx --outdir  <path>/upload/

Somehow event is triggered twice as soon as PDF is generated. Entries are as under:

somedoc.pdf##@@##CLOSE_WRITE,CLOSE##@@##<path>/upload/
somedoc.pdf##@@##CLOSE_WRITE,CLOSE##@@##<path>/upload/

What else is wrong here?

Regards

ffeast

It's triggered twice because this is how soffice appears to behave internally. One day it may start writing it 10 times and doing sleep 2 between such writes during a single run, our program can't and I believe shouldn't anticipate it and depend on it.

So I'd try solving the problem from a different angle - lets just put the converted file into a temporary directory and then move it to the target dir, like this:

soffice --headless --convert-to pdf:writer_pdf_Export <path>/upload/somedoc.docx --outdir <path>/tempdir/ && mv <path>/tempdir/somedoc.pdf <path>/upload/

and use inotifywait in the following way:

inotifywait -r -e moved_to  -m "<path>/upload" --format '%f##@@##%e##@@##%w'

The advantage is that you no longer depend on soffice's internal logic. If you can't adjust behavior of the script producing the pdf files then indeed you'll need to resort to a workaround like @Tarun suggested.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Docx to Pdf Converter in Java

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

分類Dev

jQuery: Finish dragging without triggering click event

分類Dev

stopping mousewheel event from happening twice in OSX

分類Dev

How to prevent ng-click's triggering twice on label tag?

分類Dev

drag and drop event fires twice

分類Dev

React - Triggering click event on table row

分類Dev

bot framework conversationUpdate event seems to fire twice

分類Dev

Azure Scheduled Web job is triggering twice sometimes

分類Dev

React HOC DOM properties are triggering 'Unknown event handler property'

分類Dev

How to convert PDF to DOCX or URL to DOCX with NodeJS?

分類Dev

How can converting a pointer to `void*` twice be invalid?

分類Dev

HTML5 video timeupdate event not triggering while focused on other tab in chrome

分類Dev

How to fix keypress event for enter key that is running a function twice while only being called once

分類Dev

Click event not triggering for every iteration of for loop

分類Dev

Error while Converting to Json Object

分類Dev

Sharepoint 2010 event receiver ItemUpdated fires twice

分類Dev

Is there any implications in converting doc to docx?

分類Dev

Converting PDF to PDF/A? (for embedding fonts)

分類Dev

Attach click event to body via button click without immediately triggering it

分類Dev

JavaScript Event Listener runs twice

分類Dev

Event triggering on slide appearance

分類Dev

`mousemove` and triggering a custom event

分類Dev

Triggering an event in c# from c++ and declaring LPCWSTR

分類Dev

Stop Triggering Event on Page Load

分類Dev

Converting a while loop to a do while loop

分類Dev

Attempting to Attach a CSV, Converting to PDF

Related 関連記事

  1. 1

    Docx to Pdf Converter in Java

  2. 2

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  3. 3

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  4. 4

    How can i avoid a deadlock in Spring when creating a bean while triggering an application event?

  5. 5

    jQuery: Finish dragging without triggering click event

  6. 6

    stopping mousewheel event from happening twice in OSX

  7. 7

    How to prevent ng-click's triggering twice on label tag?

  8. 8

    drag and drop event fires twice

  9. 9

    React - Triggering click event on table row

  10. 10

    bot framework conversationUpdate event seems to fire twice

  11. 11

    Azure Scheduled Web job is triggering twice sometimes

  12. 12

    React HOC DOM properties are triggering 'Unknown event handler property'

  13. 13

    How to convert PDF to DOCX or URL to DOCX with NodeJS?

  14. 14

    How can converting a pointer to `void*` twice be invalid?

  15. 15

    HTML5 video timeupdate event not triggering while focused on other tab in chrome

  16. 16

    How to fix keypress event for enter key that is running a function twice while only being called once

  17. 17

    Click event not triggering for every iteration of for loop

  18. 18

    Error while Converting to Json Object

  19. 19

    Sharepoint 2010 event receiver ItemUpdated fires twice

  20. 20

    Is there any implications in converting doc to docx?

  21. 21

    Converting PDF to PDF/A? (for embedding fonts)

  22. 22

    Attach click event to body via button click without immediately triggering it

  23. 23

    JavaScript Event Listener runs twice

  24. 24

    Event triggering on slide appearance

  25. 25

    `mousemove` and triggering a custom event

  26. 26

    Triggering an event in c# from c++ and declaring LPCWSTR

  27. 27

    Stop Triggering Event on Page Load

  28. 28

    Converting a while loop to a do while loop

  29. 29

    Attempting to Attach a CSV, Converting to PDF

ホットタグ

アーカイブ