I'm trying to run inotifywait as daemon by this command:

root@server:/# inotifywait -mrd -e delete -e delete_self -e create -e moved_from -e moved_to /path -o /tmp/path.log

But I'm getting this error:

inotifywait: invalid option -- 'd'

What am I doing wrong?

  • Don't cross-post with serverfault, it is evil! After your question was (unfairly) closed there, or you didn't get useful answers, is it ok to re-post. But only after that.
    – peterh
    Mar 22, 2015 at 11:05
  • Crosspost:serverfault.com/questions/677345/…
    – peterh
    Mar 22, 2015 at 11:06
  • Don't provide -m with -d as it's implied. With -d you must provide -o {logfile}. Mar 22, 2015 at 12:16
  • @roaima This is whole command I use: inotifywait -rd -e delete -e delete_self -e create -e moved_from -e moved_to /tmp -o /tmp/path.log and unfortunately still doesn't work.
    – Martin
    Mar 22, 2015 at 14:03
  • 1
    Your command works for me. I'm running version 3.14 as given by inotifywait -h. I would assume, therefore, that you're running an earlier version that doesn't have the -d flag. Mar 22, 2015 at 14:13

2 Answers 2


There was a problem with inotifywait version. While v3.14 has -d and -o parameters, older version 3.13 hasn't.

This can solve that:

inotifywait -qmr -e modify,delete,delete_self,create,moved_from,moved_to /path |
while read line; do
        echo $line >> /tmp/watch.log

And runs with & at the end of command.

  • Can't you simply use >> redirection after the command? What's the loop for?
    – Atsby
    Mar 22, 2015 at 18:54

On my system, I get a different error:

-o must be specified with -d

So ... try specifying -o? Or simply background it with & instead (in sh-compatible shells at least).

  • Yes I'm specifying -o and just forgot to add to the command in question I just corrected.
    – Martin
    Mar 22, 2015 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .