First of all we will need a script that allows us to use the Joomla class JDatabase. To do this we need to define a few constants and then include various library files. Place code like this in your php script.
Now Joomla is up and running we can begin to use the JDatabase class the same as if we were writing code within a component, module or plugin. The example I'm going to use is very simple but it will give you an idea of how to work with the database.
This is a very basic script that will create a table called cron and place the current date and time in that table every time it is run. Admittedly, this is a pointless exercise but the key thing here is looking at how to get a component called JCron to run this script. You can create your own complex database queries later ;).
Store the entire script somewhere on your site. I created a folder called cron in the main site directory and placed the script there.
Install JCron and enable cron jobs. In the component parameters set the following options:
Next, assuming your script file is called cron.php, you will want to set up the a cron job as follows:
This setup will run the file cron.php every time someone accesses your site. It will not run if there are no visits to your site. This is a useful way to set up cron jobs for a novice and a good workaround if you don't have shell access to your server.