The best way to do it is to use cron. It's a daemon which can be instructed to execute given commands at a given time. It reads the commands and time from a file called crontab. To edit crontab, simply type crontab -e as root in a shell. So to delete everything from /temp every midnight, you would type:
00 00 * * * rm -rf /temp/*
Then save the file and exit.