Skip to main content

Cron Job Setup

The BC Export system runs automatically via server cron jobs. This guide shows you how to install and verify the cron jobs.

Overview

Two cron scripts handle the Business Central export:

ScriptFrequencyPurpose
bc-insert-items.phpEvery 10 minutesPush orders to Business Central
bc-verify-items.phpEvery 10 minutesVerify BC processing & get Sales Order numbers

Installation

Linux/Mac Server

  1. Open crontab editor:

    crontab -e
  2. Add these lines (adjust paths for your installation):

    # GSM Middleware — BC Insert Items (every 10 minutes)
    */10 * * * * /usr/bin/php /var/www/html/wp-content/plugins/gsm-middleware/cron/bc-insert-items.php >> /var/log/gsm-middleware/bc-insert-items.log 2>&1

    # GSM Middleware — BC Verify Items (every 10 minutes)
    */10 * * * * /usr/bin/php /var/www/html/wp-content/plugins/gsm-middleware/cron/bc-verify-items.php >> /var/log/gsm-middleware/bc-verify-items.log 2>&1
  3. Save and exit

  4. Verify:

    crontab -l | grep "GSM Middleware"

Windows Server (Task Scheduler)

  1. Open Task Scheduler
  2. Create task for BC Insert:
    • Name: GSM BC Insert Items
    • Trigger: Every 10 minutes
    • Action: C:\php\php.exe
    • Arguments: C:\inetpub\wwwroot\wp-content\plugins\gsm-middleware\cron\bc-insert-items.php
  3. Repeat for BC Verify

Testing

Test manually before installing:

php wp-content/plugins/gsm-middleware/cron/bc-insert-items.php

Expected output:

[2026-03-17 12:00:00 UTC] GSM BC Insert Items starting...
Processed: 10, Success: 10, Failed: 0
[2026-03-17 12:00:05 UTC] GSM BC Insert Items complete in 5s.

Monitoring

Check logs:

tail -f /var/log/gsm-middleware/bc-insert-items.log

Next Steps