There's nothing there to schedule a task -- all that code will do is keep the code from running except between midnight and one AM and noon and one PM if something else calls your PHP page. The code may never run, or it may run multiple times.
What you need to do is remove the time-sensitive code and set up a cron job to launch the PHP script instead. You can start by looking at this tutorial.