You are doing an infinite while loop and hope that you are able to capture at EXACTLY 12:00:00 ? Hmmm..... usually for such task, we use the crontab to configure and it seems quite pretty accurate. How cron daemon is implemented to be so accurate is beyond me but as long as it provide me the feature to do what I want, I am happy. You may want to check out crontab ? :P