HOW TO create and test Cron Job procedure for my site

Talk and info about common issues

Moderator: alexandrleonenko

Site Admin
Site Admin
Posts: 6037
Joined: Jan 7th, '09, 23:18

HOW TO create and test Cron Job procedure for my site

Postby administrator » Apr 20th, '11, 10:50

The Cron Job feature is already exist in the script.
To change settings or write your own procedure, following the instructions below:

1. Settings.
Change settings according to your needs. To do this, go to General -> Settings -> Cron Jobs.
On this page you may change settings of running Cron Jobs.
Remember, that you may run it remotely (Batch - using your server to call cron procedure) or simultaneously
(Non-batch - when cron procedure is called every time some visit your site)

Example of Batch Cron job command:

Code: Select all

 php $HOME/public_html/cron.php >/dev/null 2>&1

To block remote access to cron.php, in the server's .htaccess file or vhost configuration file add this section:

Code: Select all

<Files "cron.php">
   Order Deny,Allow
   Deny from all
   Allow from localhost
   Allow from
   Allow from xx.xx.xx.xx <-- add here your IP address (allowed)

Remember: Setup of your cron command is depending on your server and hosting settings.
Here the instructions for CPanel: cPanel Cron Jobs Tutorial

2. Add your own procedure.
To add your procedure in cron, open includes/Cron.class.php file and find there Run() method or call to other classes.
You may write your own procedure/code in this method.

3. Test your procedure.
After cron procedure was added, simply test it by running you site and massive calling of index.php file.

Return to “ApPHP MicroCMS {HOW TO}”