0

I have project in django and I'm trying to run my crontask:

Here is my code in crontab:

30 12 * * * cd /path/to/file/in/project/apps && python import.py

but this code doesn't works for me. Please for any hint. Thanks a lot.

3
  • What means doesn't works for me any error messages or what?
    – Jens
    Aug 2, 2017 at 10:31
  • @Jens normaly when I run command with python import.py is OK, but with crontab not working and I don't know why.
    – Kai
    Aug 2, 2017 at 10:34
  • Check what's going wrong in /var/log/cron.log. Without error message it's difficult to help.
    – jagatjyoti
    Aug 2, 2017 at 10:39

1 Answer 1

0

Is the virtual environment activated when you run the command manually? Try using the path of the virtualenv. You can also create a log to check the result of cront:

30 12 * * * path/to/app/virtualenv/bin/python /path/to/app/import.py >> /path/yourcron.log  2>&1
2
  • I created .sh file #!/bin/bash #source $HOME/.profile cd /nfs/koelner-philharmonie/koelner-philharmonie/staging source venv/bin/activate cd apps python coda_import.py but also without success
    – Kai
    Aug 2, 2017 at 12:46
  • Did you try using the format I commented above? Run it in the terminal, if it works, it should also work on the cron. Don't forget to change the frequency for tests. Did you set a log? Don't forget the 2>&1 at the end Aug 2, 2017 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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