virgil-ai/scripts
2025-07-28 20:33:11 +03:00
..
README.md add insurance processor script 2025-07-28 20:33:11 +03:00
run_insurance_processor.sh add insurance processor script 2025-07-28 20:33:11 +03:00

Insurance Plan Processor Cron Setup

This directory contains scripts for running the insurance plan processor as a scheduled task.

Files

  • run_insurance_processor.sh - Main script to run the insurance plan processor from within the Docker container

Setup Instructions

1. Test the Script

First, test that the script works correctly:

./scripts/run_insurance_processor.sh

2. Set up Cron Job

Add a cron job to run the script at your desired interval. For example, to run it daily at 2 AM:

# Open crontab for editing
crontab -e

# Add one of these lines depending on your needs:

# Run daily at 2 AM
0 2 * * * /path/to/lolly-ai/scripts/run_insurance_processor.sh

# Run every 6 hours
0 */6 * * * /path/to/lolly-ai/scripts/run_insurance_processor.sh

# Run every hour
0 * * * * /path/to/lolly-ai/scripts/run_insurance_processor.sh

# Run every 30 minutes
*/30 * * * * /path/to/lolly-ai/scripts/run_insurance_processor.sh

3. Verify Cron Job

Check that your cron job was added correctly:

crontab -l

4. Monitor Logs

The script creates logs in the logs/ directory:

  • logs/insurance_processor.log - General execution logs
  • logs/insurance_processor_error.log - Error logs

Monitor these files to ensure the script is running correctly:

# View recent logs
tail -f logs/insurance_processor.log

# View error logs
tail -f logs/insurance_processor_error.log

Prerequisites

  • Docker Compose must be running with the lolly-ai service
  • The .env file must be properly configured with API keys
  • The script must have execute permissions (chmod +x scripts/run_insurance_processor.sh)

Troubleshooting

Common Issues

  1. Docker service not running: The script checks if the Docker Compose service is running and will log an error if it's not.

  2. Permission denied: Make sure the script is executable:

    chmod +x scripts/run_insurance_processor.sh
    
  3. Path issues: Make sure to use the full path to the script in your cron job.

  4. Environment variables: The script uses the .env file from the project directory, so make sure it's properly configured.

Debugging

To debug cron issues, you can temporarily run the script manually and check the logs:

# Run manually
./scripts/run_insurance_processor.sh

# Check logs
cat logs/insurance_processor.log
cat logs/insurance_processor_error.log

Cron Schedule Examples

Schedule Description
0 2 * * * Daily at 2 AM
0 */6 * * * Every 6 hours
0 * * * * Every hour
*/30 * * * * Every 30 minutes
0 2 * * 1 Every Monday at 2 AM
0 2 1 * * First day of each month at 2 AM