Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a user, dropbox, that runs the Dropbox daemon, I want to monitor the directories in the Dropbox directory for new files and run a python script when they appear.

I have the python script that I know works:

$ /home/dropbox/
Trying to get lock
Got lock, waiting for Dropbox to be idle
Dropbox idle
Finding instructions
Done, releasing lock

I have an incrontab entry:

$ incrontab -l
/home/dropbox/Dropbox IN_CREATE /home/dropbox/ | logger
/home/dropbox/test IN_CREATE logger "$$ $@ $# $% $&"

When I add a file to the test directory I see the output in /var/log/syslog:

$ touch /home/dropbox/test/a
$ tail /var/log/syslog
Nov  9 10:18:27 vps incrond[1354]: (dropbox) CMD (logger "$ /home/dropbox/test a IN_CREATE 256")
Nov  9 10:18:27 vps logger: "$ /home/dropbox/test a IN_CREATE 256"

However, when I add a file to the Dropbox directory the command doesn't seem to run:

$ touch /home/dropbox/Dropbox/a
$ tail /var/log/syslog
Nov  9 10:24:16 vps incrond[1354]: (dropbox) CMD (/home/dropbox/ | logger)

So the incron daemon notices the new file and the correct command is found to be executed but it never actually gets executed. Nor are there any error messages. It kind of seems like incrontab can only be used to run the most simple of commands.

This might be a similar question to:

but I think that I don't have env problems, every path is absolute. I tried changing .../ to /usr/bin/python2.7 .../ just in case but it didn't make any difference.


Dennis Kaarsemaker offered a solution that incrontab was executing my command in a non-cron manner and that this might be causing the problem. Unfortunately, I still can't get it to work.

First I removed the extra stuff from the incrontab:

$ incrontab -l
/home/dropbox/Dropbox IN_CREATE /home/dropbox/

This should run just my monitor file and not try to pass anything in as arguments. No dice, still no output.

Then I created a bash script that contained the execution instruction for my script:

$ vim
logger "$PATH"
/usr/bin/python2.7 /home/dropbox/ | logger

This produces the following output:

$ tail /var/log/syslog
Nov  9 23:50:28 vps incrond[1354]: (dropbox) CMD (/home/dropbox/
Nov  9 23:50:28 vps logger: /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin

So nothing from and we can see that the directory containing python is in incrontab's environment, so we shouldn't even need to specify the path as absolutely as we do.

share|improve this question

There's a big difference between cron and incron: the way they execute the commands. Cron sees the command as one argument and calls a shell to run it. Roughly like this:

execvp('/bin/sh', ['/bin/sh', '-c', 'whatever is in the crontab']);

So all shell constructs like && and | work. Incron does not do this, it parses the command itself and execs it directly. So what incron runs in your case is:

execvp('/home/dropbox/', ['/home/dropbox/', '|', 'logger']);

So your gets run with | and logger as arguments. You can either wrap your script in another script that does | logger or use the python logging module to do the logging from itself.

share|improve this answer
I did some experimenting, I'm going to update my question with what I've done. Long story short, I still can't get the script to run. – WilliamMayor Nov 9 '13 at 23:56

I feel like an idiot for noticing this one.

My script attempts to get a file lock before it starts messing around with dropbox stuff. This is mostly to stop other instances of from interfering. The path to the file I lock wasn't absolute.

So, lesson to anybody that finds this page in the future. Check every path that you use to make sure that it's either 1) on the path 2) absolute.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.