[Answer]-Celery vs crontab to call DB shell, which is better to add regular update data into django model database?

1👍

Whether to take celery or use crontab in this particular case is quite an opinionated choice. Both solutions should work fine.

Celery is far more powerful in general and (once configured) will allow you to do more stuff like using async tasks, etc. But to get it you will have to configure and then manage it. It’s not hard but anyway you will have to spend some to to get it work.

I often use cron for simple projects because it’s much more simple and doesn’t require any additional efforts to use it. Seems like in your case it would sufficient too.

At last, asking your question 🙂 if you would prefer cron you should use custom management commands: https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/. This would allow you not to write .sh scripts. Crontab would look like this in that case:

0 0 * * * /path/to/project/python /path/to/project/manage.py your_custom_command_name

👤alTus

Leave a comment