# Setting Up CheckPendingBankStatus Command in cPanel Cron Job

## Command Details
- **Command Name**: `business:check-pending-bank-status`
- **Recommended Schedule**: Every 30 minutes (as configured in `app/Console/Kernel.php`)

## Step-by-Step Instructions

### 1. Find Your PHP Path in cPanel

1. Log into your cPanel
2. Go to **Software** → **Select PHP Version** (or **MultiPHP Manager**)
3. Note the PHP version you're using (e.g., PHP 8.1, PHP 8.2)
4. The PHP path will typically be one of these:
   - `/usr/bin/php` (default)
   - `/usr/local/bin/php81` (for PHP 8.1)
   - `/usr/local/bin/php82` (for PHP 8.2)
   - `/opt/cpanel/ea-php81/root/usr/bin/php` (cPanel EasyApache)
   - `/opt/cpanel/ea-php82/root/usr/bin/php` (cPanel EasyApache)

**Alternative Method**: SSH into your server and run:
```bash
which php
```
This will show the full path to PHP.

### 2. Find Your Project Path

Your project path should be something like:
- `/home/username/public_html/Gocente` (if in public_html)
- `/home/username/Gocente` (if outside public_html)
- `/home/username/domains/yourdomain.com/Gocente` (if using domain-based structure)

**To verify**: In cPanel File Manager, navigate to your Laravel project root and check the path shown in the address bar.

### 3. Set Up the Cron Job in cPanel

1. Log into cPanel
2. Navigate to **Advanced** → **Cron Jobs**
3. Click **Add New Cron Job** or **Edit** if you're modifying an existing one

### 4. Configure the Cron Job

**Option A: Using the cPanel Interface (Recommended)**

- **Minute**: `*/30` (every 30 minutes)
- **Hour**: `*` (every hour)
- **Day**: `*` (every day)
- **Month**: `*` (every month)
- **Weekday**: `*` (every day of the week)

**Command**:
```bash
/usr/bin/php /home/username/path/to/Gocente/artisan business:check-pending-bank-status --sync
```

**Replace**:
- `/usr/bin/php` with your actual PHP path from Step 1
- `/home/username/path/to/Gocente` with your actual project path from Step 2

**Option B: Using Common Line (Advanced)**

Paste this into the "Common Settings" dropdown and select **Every 30 Minutes**, then edit the command:

```bash
*/30 * * * * /usr/bin/php /home/username/path/to/Gocente/artisan business:check-pending-bank-status --sync
```

### 5. Important Notes

#### Using `--sync` Flag
The `--sync` flag runs the job synchronously (immediately) instead of queuing it. This is recommended for cron jobs because:
- No need to run a separate queue worker
- Immediate execution
- Simpler setup

#### Without `--sync` Flag
If you omit `--sync`, the command will dispatch the job to the queue. You'll need to ensure a queue worker is running:
```bash
php artisan queue:work
```

### 6. Example Cron Job Commands

**For PHP 8.1 (cPanel EasyApache)**:
```bash
*/30 * * * * /opt/cpanel/ea-php81/root/usr/bin/php /home/username/public_html/Gocente/artisan business:check-pending-bank-status --sync
```

**For PHP 8.2 (cPanel EasyApache)**:
```bash
*/30 * * * * /opt/cpanel/ea-php82/root/usr/bin/php /home/username/public_html/Gocente/artisan business:check-pending-bank-status --sync
```

**For Default PHP**:
```bash
*/30 * * * * /usr/bin/php /home/username/public_html/Gocente/artisan business:check-pank-status --sync
```

### 7. Testing the Cron Job

After setting up, you can test it manually via SSH:
```bash
cd /home/username/path/to/Gocente
php artisan business:check-pending-bank-status --sync
```

### 8. Viewing Cron Job Logs

cPanel cron jobs typically log to:
- `/home/username/public_html/cron.log` (if you set up logging)
- Check cPanel → **Cron Jobs** → **Current Cron Jobs** for execution status

To add logging to your cron job, modify the command:
```bash
*/30 * * * * /usr/bin/php /home/username/path/to/Gocente/artisan business:check-pending-bank-status --sync >> /home/username/public_html/cron.log 2>&1
```

### 9. Alternative: Using Laravel Scheduler (If Available)

If your hosting allows long-running processes, you can use Laravel's scheduler instead:
```bash
* * * * * /usr/bin/php /home/username/path/to/Gocente/artisan schedule:run >> /dev/null 2>&1
```

This runs Laravel's scheduler every minute, which will execute the command based on the schedule defined in `app/Console/Kernel.php`.

## Troubleshooting

### Command Not Found
- Verify the PHP path is correct
- Verify the project path is correct
- Ensure the `artisan` file exists in the project root

### Permission Denied
- Ensure the PHP file is executable
- Check file permissions on the project directory

### No Output
- Add logging to see what's happening
- Check Laravel logs: `storage/logs/laravel.log`
- Verify the command works when run manually via SSH




