Setting a cron job to visit a url

Cron jobs help to run a script on a given interval. You can set a cron job to visit a web page on a given time.  This article explains how to create a cron job easily in cpanel.

First log in to cpanel and click the cron jobs button. In most cpanels this is in the Advanced section at the bottom.

advanced tab on cpanel

Then you will get the screen where you can set a cron job.

cron job

In this screen first select the interval you want to run the script. Most of the time your required interval will be on the list of common settings.

Then in the command box enter following code.

wget -q -O - http://www.example.com/ >/dev/null 2>&1

Make sure to replace your url with example.com.  Here the code >/dev/null 2>&1 make sure no email is sent to admin email once a cron job is done successfully. Remove that part from the command if you like to receive email. But be aware that this can end up with filling your inbox with hundreds of emails from cron job.

This method can be used to set up cron jobs for wordpress too. It will be helpful for wordpress plugins which requires a better cron schedule.

Enjoyed this article? Share with friends

Subscribe

Subscribe to our email feed and never miss a post

Join Us