views:

36

answers:

3

Hello,

In my django project I would like to be able to delete certain entries in the database automatically if they're too old. I can write a function that checks the creation_date and if its too old, deletes it, but I want this function to be run automatically at regular intervals..Is it possible to do this? Thanks

+4  A: 

This is what cron is for.

Daniel Roseman
A: 

What you require is a cron job.

A cron job is time-based job scheduler. Most web hosting companies provide this feature which lets u run a service or a script at a time of your choosing. Most Unix-based OSes have this feature.

You would have better direct help asking this question on serverfault.com, the sister site of stackoverflow.

Ali
+1  A: 

You will be better off reading this section of the Django docs http://docs.djangoproject.com/en/1.2/howto/custom-management-commands/#howto-custom-management-commands

Then you can create your function as a Django management command and use it in conjunction with cron on *nix (or scheduled tasks on Windows) to run it on a schedule.

See this for a good intro guide to cron http://www.unixgeeks.org/security/newbie/unix/cron-1.html

chefsmart