Run functions by CRON

<< Cliquez pour afficher la table des matières >>

Navigation:  »main«

Run functions by CRON

DataLife Engine has the ability to run some functions on schedule. You can automatically create a backup of the database to optimize the database, and create a sitemap for search engines.  This requires your hosting to support the feature of running applications on schedule (CRON). cron.php is a file that is designed to run functions by cron, and it is located in the root of your site. For security reasons the ability to run this file is disabled by default, so let's consider how you can enable this feature.

 

Firstly, we recommend you to change the name of cron.php file to any other with the .php extension for security.

 

Next, open the file in a text editor and locate the following line in the very beginning:

 

$allow_cron = 0;

 

Change it to:

 

$allow_cron = 1;

 

Thus, you allow the file to perform the functions in automatic mode.

 

Then you can change the number of database backup files that will be stored on the server. To do this, locate the following line:

 

$max_count_files = 5;

 

where 5 is the number of copies of the database. You can put your own number of files. When exceeding this limit older backups of the database are automatically deleted.

 

Once you have made your changes, save the file on the server. Now you need to add this file to be run on a schedule (CRON). Creation time and periodicity you set by yourself. For detailed instructions on how to add this file to the CRON function, please contact your hosting provider.

 

Cron file can perform the following operations:

 

1. Create a database backup.

Just run cron.php file without specifying any parameters to start this mode.

 

2. Creating a site map of the site.

Run the file with the following parameter to start this mode: cron.php?cronmode=sitemap

Use php -f cron.php sitemap if you are using a console to launch the script.

 

When creating a site map using cron, the automatic notification of a search engines about this site map will be performed.

 

3. Optimizing the database.

Run the file with the following parameter to start this mode: cron.php?cronmode=optimize

Use php -f cron.php optimize if you are using a console to launch the script.

 

4. Run the antivirus.

Run the file with the following parameter to start this mode: cron.php?cronmode=antivirus

Use php -f cron.php antivirus if you are using a console to launch the script.

 

Thus, you must not forget about specifying the right paths from the root directory of your server both to the PHP interpreter and to the script itself.