Purchase Now
Critical Requirement

Cron jobs are essential for CoinTrail to function properly. Without cron jobs, cryptocurrency prices won't update, news won't be fetched, and many features will not work.

Setting Up the Cron Job

CoinTrail uses Laravel's task scheduler. You only need to add one cron entry to your server, and Laravel will handle all scheduled tasks.

Linux/Unix Servers

Add this entry to your server's crontab:

Crontab
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

To edit crontab:

Terminal
# Edit crontab for current user
crontab -e

# Or for www-data user (recommended)
sudo crontab -u www-data -e

Replace /path-to-your-project with your actual project path, e.g., /var/www/html/cointrail

Hostinger (hPanel)

Hostinger uses its own control panel (hPanel) for cron job management. Follow these steps:

  1. Log in to hPanel
  2. Navigate to Advanced → Cron Jobs
  3. Click Create to add a new cron job
  4. Configure the cron job:
    • Run cron every: 1 minute (use "Custom" and enter * * * * * if needed)
    • Command: Use one of the following based on your PHP version:
Important: PHP Path on Hostinger

Hostinger shared hosting requires explicit PHP paths. Use the path matching your PHP version (check in hPanel → Website → Configuration → PHP Configuration).

For PHP 8.4:

Cron Command
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html && /opt/alt/php84/usr/bin/php artisan schedule:run

For PHP 8.3:

Cron Command
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html && /opt/alt/php83/usr/bin/php artisan schedule:run

For PHP 8.2:

Cron Command
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html && /opt/alt/php82/usr/bin/php artisan schedule:run

Alternative: Using a Shell Script

If the direct command doesn't work, create a shell script:

  1. Create a file named cron.sh in your project root with this content:
cron.sh
#!/bin/bash
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html
/opt/alt/php84/usr/bin/php artisan schedule:run >> /dev/null 2>&1
  1. Make it executable via SSH: chmod +x cron.sh
  2. Use this command in hPanel cron:
Cron Command
/home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html/cron.sh

Replace YOUR_USERNAME with your Hostinger username (e.g., u179766331) and YOUR_DOMAIN with your domain name.

cPanel Servers

  1. Log in to cPanel
  2. Navigate to Advanced → Cron Jobs
  3. Under "Add New Cron Job", set:
    • Common Settings: Once Per Minute (* * * * *)
    • Command: cd /home/username/public_html && php artisan schedule:run >> /dev/null 2>&1
  4. Click Add New Cron Job
Screenshot: cPanel Cron Jobs configuration page with the scheduler command entered technical/cpanel-cron-configuration.png

Adding a cron job in cPanel - set to run every minute with the Laravel scheduler command

Plesk Servers

  1. Log in to Plesk
  2. Go to Websites & Domains → Scheduled Tasks
  3. Click Add Task
  4. Set task type to Run a command
  5. Enter: cd /var/www/vhosts/yourdomain.com/httpdocs && php artisan schedule:run
  6. Set schedule to "Every minute"
Screenshot: Plesk Scheduled Tasks panel showing the cron job configuration technical/plesk-scheduled-tasks.png

Configuring scheduled tasks in Plesk control panel

Windows Servers (Task Scheduler)

  1. Open Task Scheduler
  2. Create a new Basic Task
  3. Set trigger to repeat every 1 minute
  4. Action: Start a program
  5. Program: php
  6. Arguments: artisan schedule:run
  7. Start in: C:\path\to\cointrail

Scheduled Tasks Overview

CoinTrail automatically runs the following tasks:

Screenshot: List of all scheduled tasks displayed by php artisan schedule:list command technical/scheduled-tasks-list.png

Output of php artisan schedule:list showing all configured scheduled tasks and their frequencies

Price Updates (Tiered System)

Task Default Frequency Description
Top Coins Price Update Every 5 minutes Updates prices for top 100 cryptocurrencies (configurable)
Remaining Coins Update Every 6 hours Updates prices for coins outside top 100
Global Market Data Every 5 minutes Total market cap, Bitcoin dominance, etc.

News & Content

Task Frequency Description
Crypto News Fetch Hourly Fetches latest cryptocurrency news
News Aggregation Daily (11:15 AM) Aggregates news from multiple sources
Sitemap Generation Daily (9:15 PM) Regenerates XML sitemap

Market Data

Task Frequency Description
Fear & Greed Index Twice daily (1 AM, 2 PM) Updates market sentiment data
Currency Exchange Rates Every 6 hours Updates fiat currency rates
Historical Data Daily Fetches daily OHLCV data
Trading Pairs Weekly Updates trading pair data
Exchange Data Weekly Updates exchange information

User-Related Tasks

Task Frequency Description
Price Alert Check Every 5 minutes Checks and sends price alert notifications
Newsletter Weekly (Sunday 11:15 PM) Sends weekly newsletter to subscribers
License Verification Daily Verifies license status

Maintenance Tasks

Task Frequency Description
Cache Clear Weekly Clears old cache data
Crypto Icons Update Weekly Updates cryptocurrency icons

Configuring Update Intervals

You can configure price update intervals from the admin panel:

  1. Go to Admin Panel → Cron Settings (or API Settings)
  2. Configure the following options:
Screenshot: CoinTrail admin panel Cron Settings page with update interval configuration options technical/admin-cron-settings.png

Admin panel Cron Settings page - configure update intervals, API plans, and tiered update options

Setting Description Recommended Values
CoinGecko Plan Your CoinGecko API plan Demo (free), Analyst, Pro
Top Coins Count Number of coins updated frequently 100 (adjustable 50-500)
Top Coins Interval Update frequency for top coins 5 minutes (Demo), 1 minute (Pro)
Remaining Coins Interval Update frequency for other coins 6 hours (Demo), 30 minutes (Pro)
Enable Tiered Updates Enable different update frequencies Yes (saves API calls)
CoinGecko API Limits

The free Demo plan allows ~10,000 API calls/month. CoinTrail is optimized to stay within these limits with default settings. If you need more frequent updates, consider upgrading to a paid CoinGecko plan.

Manual Artisan Commands

You can run tasks manually via SSH for testing or immediate updates:

Price Updates

Terminal
# Update all crypto prices
php artisan crypto:update-prices

# Update only top 100 coins
php artisan crypto:update-prices --tier=top --limit=100

# Update remaining coins
php artisan crypto:update-prices --tier=remaining --offset=100

# Fetch data from CoinGecko
php artisan coingecko:fetch

Market Data

Terminal
# Update Fear & Greed Index
php artisan feargreed:update

# Update currency exchange rates
php artisan currency:update-rates

# Sync exchanges from CoinGecko
php artisan sync:exchanges

User Tasks

Terminal
# Check and send price alerts
php artisan alerts:check

# Send portfolio summary emails
php artisan portfolio:send-summary

Maintenance

Terminal
# Clear all caches
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear

# Optimize application
php artisan optimize

# View scheduled tasks
php artisan schedule:list

Monitoring Cron Jobs

Screenshot: Cron job execution history and logs showing successful task runs with timestamps technical/cron-task-history-logs.png

Task run history showing execution times, status, and any errors encountered during scheduled task runs

Check Cron Logs

View price update logs:

Terminal
# View recent price update logs
tail -f storage/logs/price-updates.log

# View Laravel application log
tail -f storage/logs/laravel.log

Verify Cron is Running

Terminal
# Check if cron service is running
systemctl status cron

# View cron logs
grep CRON /var/log/syslog

# List scheduled tasks
php artisan schedule:list

Test Scheduler

Terminal
# Run scheduler manually (for testing)
php artisan schedule:run

# Run scheduler in verbose mode
php artisan schedule:run --verbose

Troubleshooting

Check these items:

  1. Verify cron is set up: crontab -l
  2. Check if scheduler runs: php artisan schedule:run
  3. View logs: tail -f storage/logs/price-updates.log
  4. Check CoinGecko API connectivity
  5. Verify API rate limits aren't exceeded

Possible causes:

  • Wrong PHP path: Use full PHP path (e.g., /usr/bin/php)
  • Wrong project path: Verify the path in crontab is correct
  • Permission issues: Ensure www-data can execute the command
  • PHP CLI errors: Run php artisan schedule:run manually to see errors

Solutions:

  • Increase update intervals in admin settings
  • Reduce the number of "top coins" to update frequently
  • Enable tiered updates to prioritize important coins
  • Consider upgrading to a paid CoinGecko plan
  • Add a CoinGecko API key in settings for higher limits

Solutions:

  • Increase PHP memory limit: memory_limit = 256M
  • Increase max execution time: max_execution_time = 300
  • Check server available RAM
  • Reduce batch sizes for updates

Best Practices

  • Monitor logs regularly - Check storage/logs/ for errors
  • Start with default settings - The defaults are optimized for free API plans
  • Use tiered updates - Prioritize top coins for better user experience
  • Set up monitoring - Use tools like UptimeRobot to monitor your site
  • Backup before changes - Always backup before modifying cron settings