To handle scheduled tasks, you need to set up cron job via cPanel.
First, you need to disable the file to be hit every time someone loads your pages. To do this, open the wp-config.php file in your website folder and add this line at the end, before the closing ?> tag:
Then you can set up cron via cPanel. Open cpanel and find there Cron Jobs section.
When you open it, there will be offer to set up an email sent to you each time when cronjob is executed successfully. You can add your email just to be sure that it works ok.
Below you will see a list of preset intervals. Select Every 30 minutes from the minutes drop-down and leave a * symbol in the rest of fields.
Add command below where /user/ must be your cPanel username.
Click on Add new Cron Job button. You will see this cron job in a list of cron jobs which can be removed or edited.