Cron Jobs & Scheduling
Configure scheduled tasks for automatic price updates, news fetching, and more.
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:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
To edit crontab:
# 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:
- Log in to hPanel
- Navigate to Advanced → Cron Jobs
- Click Create to add a new cron job
- 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:
- Run cron every: 1 minute (use "Custom" and enter
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:
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html && /opt/alt/php84/usr/bin/php artisan schedule:run
For PHP 8.3:
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html && /opt/alt/php83/usr/bin/php artisan schedule:run
For PHP 8.2:
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:
- Create a file named
cron.shin your project root with this content:
#!/bin/bash
cd /home/YOUR_USERNAME/domains/YOUR_DOMAIN/public_html
/opt/alt/php84/usr/bin/php artisan schedule:run >> /dev/null 2>&1
- Make it executable via SSH:
chmod +x cron.sh - Use this command in hPanel cron:
/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
- Log in to cPanel
- Navigate to Advanced → Cron Jobs
- 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
- Click Add New Cron Job
Adding a cron job in cPanel - set to run every minute with the Laravel scheduler command
Plesk Servers
- Log in to Plesk
- Go to Websites & Domains → Scheduled Tasks
- Click Add Task
- Set task type to Run a command
- Enter:
cd /var/www/vhosts/yourdomain.com/httpdocs && php artisan schedule:run - Set schedule to "Every minute"
Configuring scheduled tasks in Plesk control panel
Windows Servers (Task Scheduler)
- Open Task Scheduler
- Create a new Basic Task
- Set trigger to repeat every 1 minute
- Action: Start a program
- Program:
php - Arguments:
artisan schedule:run - Start in:
C:\path\to\cointrail
Scheduled Tasks Overview
CoinTrail automatically runs the following tasks:
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:
- Go to Admin Panel → Cron Settings (or API Settings)
- Configure the following options:
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) |
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
# 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
# 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
# Check and send price alerts
php artisan alerts:check
# Send portfolio summary emails
php artisan portfolio:send-summary
Maintenance
# 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
Task run history showing execution times, status, and any errors encountered during scheduled task runs
Check Cron Logs
View price update logs:
# 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
# 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
# Run scheduler manually (for testing)
php artisan schedule:run
# Run scheduler in verbose mode
php artisan schedule:run --verbose
Troubleshooting
Check these items:
- Verify cron is set up:
crontab -l - Check if scheduler runs:
php artisan schedule:run - View logs:
tail -f storage/logs/price-updates.log - Check CoinGecko API connectivity
- 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:runmanually 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