I want to develop a timer for my 6681, it can reboot/shutdown my 6681 at the appointed time. So, who can help me to solve the following problems?

1. How to shutdown the device?
2. How to reboot the device?
3. How to save the time that user set up?
4. What's the run mode? I think it should be run at background, need thread?