Getting Started Questions

I am creating a simple web application that goes out and looks for equipment sitting on a ZeroTier network and updating a database with this information. The web site, at this time, has really just a single page showing the information that is stored in the db (SQLite). Being new to django I am curious where to put this code. I understand the use of apps and that each has its own templates, models, views and urls. But where does one put a background task that runs periodically? In a separate app? In the app for the main and only page/view? In the project? It does not seem to fir the ‘app’ concept. At least not to me.

Along with that what is the simplest way to kick off a background task, ping a list of IP Addresses and if ping succeeds open a TCP/IP connection send a string and get one back. I suppose one could kick off multiple background tasks to do this nut let’s keep it simple for now. The hardware at the far end does not change often.

Thanks!

If you want this task to use Django features, such as the ORM, I’d create it as a custom management command. (And have done so, in many situations.)

Is this to be triggered by some event, or on a scheduled basis? If this is going to run on a schedule, I’d create it as a cron job. If it’s going to be started as the result of an event, the nature of that event would determine how I plan on starting it.

Thanks, Ken! Fast response!
OK. A custom management command, I will look this and read about this. It really is on a schedule basis and since it runs on a schedule, like every 5 minutes, putting this on as a cron job does make sense. I suppose adding a button to do a manual refresh is not such a bad idea so in this case it could be kicked off by an event. So, it looks like either is the correct answer! There is a part of me that wants to keep all this together and try and things from within the confines of the web site. I will read you suggested reading and see if that helps me.

Thanks again,
Doug