It cannot be done automatically with PHP. You would need to use a CRON job which is basically a linux scheduling program. You can set it up to run every XX seconds/minutes/days etc. It will execute any command you tell it to at that time which can be a shell script or a php script.
CodingForums Supreme Overlord
All Hail Spookster