⚙️ cPanel Shared Hosting Cron Job Database Sync Guide

Follow these steps to schedule automatic database sync every 1 to 5 minutes on your cPanel shared hosting account.

1 Enable "Remote MySQL" in cPanel (Server B)

To allow Server A to connect to Server B's MySQL database, log into Server B's cPanel:

  1. Log into your cPanel dashboard on Server B.
  2. Scroll down to the Databases section and click Remote MySQL®.
  3. In the Add Access Host field, enter the IP address of Server A.
  4. Click Add Host.
2 Upload Script & Update Credentials

Upload `cron_sync.php` and `config.php` to your website folder (e.g. public_html/cron_sync.php).

In config.php, update database credentials for Server A and Server B:

define('DB_PRIMARY_HOST', 'localhost');                  // Server A local MySQL
define('DB_REPLICA_HOST', 'SERVER_B_IP_OR_DOMAIN');     // Server B Remote Host IP
3 Add Cron Job Command in cPanel

In cPanel, click Cron Jobs and add a new schedule:

Recommended Settings:
Common Settings: Every 5 Minutes (*/5 * * * *) or Every Minute (* * * * *)
Command:
/usr/bin/php /home/YOUR_CPANEL_USER/public_html/cron_sync.php >/dev/null 2>&1
📜 Live Cron Execution Log
[2026-08-28 09:07:19] ERROR: Failed to connect to Target Database (Database B). Remote host down or Remote MySQL port blocked.
[2026-08-28 09:07:19] ERROR: Failed to connect to Target Database (Database B). Remote host down or Remote MySQL port blocked.
[2026-08-28 09:14:26] ERROR: Failed to connect to Target Database (Database B). Remote host down or Remote MySQL port blocked.
[2026-08-28 09:14:27] ERROR: Failed to connect to Target Database (Database B). Remote host down or Remote MySQL port blocked.