Knowledge Base

Setting up scheduled tasks

Article ID: 238
Last updated: 30 Oct, 2019

Some parts of KBPublisher simply will not work if you do not schedule tasks. This includes:

  • Reports. You will not be able to run reports
  • Subscription processing. Users will not be notified when items are added or changed  
  • Scheduling. You will not be able to schedule article, news or files
  • Optimization. Database tables will not be checked/repaired/optimized
  • Synchronization. Article and file hits will not be synchronized
  • Search suggest will not work 
  • Administration. Some system jobs will not run.

How do I schedule tasks?

You can configure scheduling through the Unix crontab command, through scheduled tasks in Windows, or through the Control Panel provided by your service provider.

When scheduling tasks for KBPublisher there are several files you must run periodically. 

The files to be scheduled are:

  • admin/cron/freq.php - every 5 minutes
  • admin/cron/hourly.php - hourly
  • admin/cron/daily.php - daily, just after midnight
  • admin/cron/weekly.php - weekly
  • admin/cron/monthly.php - monthly

1. By 'crontab' on Unix

# every 5 minutes
*/5 * * * *   /usr/local/bin/php [KBP_DIRECTORY]/admin/cron/freq.php

# hourly
0 * * * *    /usr/local/bin/php [KBP_DIRECTORY]/admin/cron/hourly.php

# daily, after midnight
01 0 * * *    /usr/local/bin/php [KBP_DIRECTORY]/admin/cron/daily.php

# weekly
10 0 * * 0   /usr/local/bin/php [KBP_DIRECTORY]/admin/cron/weekly.php

# monthly
20 0 1 * *   /usr/local/bin/php [KBP_DIRECTORY]/admin/cron/monthly.php

where /usr/local/bin/php is the path to the PHP interpreter, it could differ on your system (you can get it by running 'which php' on command shell), and [KBP_DIRECTORY] is the absolute path to your KBPublisher installation directory (e.g. '/home/user_name/www/kb'). Replace it with your value.

OR
# every 5 minutes
*/5 * * * *   /usr/bin/curl -s http://example.com/kb/admin/cron/freq.php

# hourly
0 * * * *    /usr/bin/curl -s http://example.com/kb/admin/cron/hourly.php

# daily, after midnight
01 0 * * *    /usr/bin/curl -s http://example.com/kb/admin/cron/daily.php

# weekly
10 0 * * 0   /usr/bin/curl -s http://example.com/kb/admin/cron/weekly.php

# monthly
20 0 1 * *   /usr/bin/curl -s http://example.com/kb/admin/cron/monthly.php
If you are using HTTP requests, as above, you should update the KBPublisher settings to allow HTTP requests and specify the allowed IP addresses.
Go to Settings -> Admin tab and check "Allow HTTP requests". Then enter the allowed IP addresses into the "Allowed IP's for HTTP requests" field.

You can insert these crontab records by executing 'crontab -e' and editing cron jobs manually, or you can create a file (kbp_cron.txt) containing these lines and execute 'crontab kbp_cron.txt' from the shell (WARNING: all existing records in crontab will be removed!).

2. By 'Scheduled Tasks' on Windows

Instead of cron on Windows you can use Scheduled Tasks. Contact your system administrator or hosting provider for additional details.
To set up Scheduled Tasks in Windows XP, Vista and 7, as well as Windows 2003 Server and later, you can use schtasks.exe. Open the command line and type in following commands:
schtasks /create /ru "System" /sc minute /mo 5 /st 00:00:00 /tn "KBPublisher freq task" /tr "[PHP_DIR]\php.exe [KBP_DIRECTORY]\admin\cron\freq.php"

schtasks /create /ru "System" /sc hourly /st 00:00:00 /tn "KBPublisher hourly task" /tr "[PHP_DIR]\php.exe [KBP_DIRECTORY]\admin\cron\hourly.php"

schtasks /create /ru "System" /sc daily /st 00:01:00 /tn "KBPublisher daily task" /tr "[PHP_DIR]\php.exe [KBP_DIRECTORY]\admin\cron\daily.php"

schtasks /create /ru "System" /sc weekly /st 00:10:00 /d SUN /tn "KBPublisher weekly task" /tr "[PHP_DIR]\php.exe [KBP_DIRECTORY]\admin\cron\weekly.php"

schtasks /create /ru "System" /sc monthly /st 00:20:00 /tn "KBPublisher monthly task" /tr "[PHP_DIR]\php.exe [KBP_DIRECTORY]\admin\cron\monthly.php"

Where: [PHP_DIR] - full path to php.exe, [KBP_DIRECTORY] - full path to KBPublisher directory. Replace it with your values

Example: schtasks /create /ru "System" /sc minute /mo 5 /st 00:00:00 /tn "KBPublisher freq task" /tr "C:\php\php.exe C:\www\kbpublisher\admin\cron\freq.php"

3. By Control Panel

This depends very much on your hosting provider. You should consult their documentation.

Notes:
  • admin/cron/freq.php should be run every 5 minutes
  • admin/cron/daily.php should be run just after midnight.

----------------------------------------------------------------------
This functionality works in version 3.5 and above

Article ID: 238
Last updated: 30 Oct, 2019
Revision: 12
Access: Public
Views: 23999
Comments: 1
Also read

Comments