How do you schedule updating the contents of a database table in Django based on time of day. For example every 5 minutes Django will call a REST api to update contents of a table.
            Asked
            
        
        
            Active
            
        
            Viewed 904 times
        
    2 Answers
1
            
            
        I think this is likely best accomplished by writing a server-side python script and adding a cronjob
 
    
    
        Rampant
        
- 148
- 5
- 
                    can you give a some detail? – MezzanineLearner Oct 12 '16 at 22:12
- 
                    I probably should have asked before , which platform is hosting the app? (Windows, OSX, Linux?) – Rampant Oct 13 '16 at 01:28
- 
                    It's hosted on Linux. – MezzanineLearner Oct 13 '16 at 09:57
1
            Based upon your question, I am not 100% clear what you are looking for. But, assuming you are looking to run some sort of a task every 5 minutes (that will make calls to the DB), then I highly suggest you look at Celery.
It is a robust task schedules, with specific Django integration. Once you get thru the getting started documentation, what you want to look at in particular is called CELERYBEAT_SCHEDULE. This allows you to sort of setup cron like calls.
This has a lot of benefits over cron, and for most use cases I find it to be a better alternative. Scalability is a huge feature for me.
Good luck!
 
    
    
        Community
        
- 1
- 1
 
    
    
        Adam Hopkins
        
- 6,837
- 6
- 32
- 52
- 
                    
- 
                    1FWIW, I also tend to use `redis` as my broker instead of RabbitMQ. I really like redis for a lot of uses, so I usually stick with it here too: http://docs.celeryproject.org/en/latest/getting-started/brokers/redis.html – Adam Hopkins Oct 12 '16 at 22:12
- 
                    
