Usually, websites have some management tasks to perform in the background on a regular interval, such as once a week, once a day, or every hour. This can be achieved by using scheduled tasks, commonly known as cron jobs. These are scripts that run on the server after the specified period of time. In this recipe, we will create two cron jobs: one to clear sessions from the database and another to back up the database data. Both will be run every night.
Setting up cron jobs for regular tasks
Getting ready
To start, deploy your Django project to a remote server. Then, connect to the server by SSH. These steps are written with the assumption that you are using a virtual environment, but a similar cron job can be created for a...