Search code examples
pythonubuntucrondocopt

Cronjob with docopt


I have a really simple code with docopt which creates a directory. The program works perfectly like this:

dbb create_dir

I need to run this using crontab in ubuntu 12.04. I used crontab -e and added this line:

0 14 * * * dbb create_dir

which should run the code on 2pm every day. My problem is this doesn't work. I checked

0 14 * * * mkdir test_dir

and it worked. So I thought the problem is not with the cron and as I could run the code without cron, I guess the main problem is the combiniation of these two. Is there any way to fix this? Thanx


Solution

  • So my friend figured it out. When I type "echo $PATH", I get this:

    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    

    I added "echo $PATH" to the crontab and the result was:

    /usr/bin:/bin
    

    So the paths are not the same. So I had to use

    /usr/local/bin/dbb create_dir
    

    instead of dbb create_dir