Run Cron Jobs When Your Hosting Doesn't Support Them
Stuck on free or budget hosting that blocks cron jobs? InfinityFree, 000webhost, Hostinger free tier, and most shared hosting providers either don't support cron or severely limit it. CronPop runs your scheduled tasks from the cloud, connecting to your database and APIs exactly when you need them.
The Free Hosting Problem
Budget and free hosting providers restrict what you can do. Sound familiar?
No Cron Access
InfinityFree, 000webhost, and free tiers simply don't offer cron jobs
Severe Limits
Shared hosting often limits you to 1 cron per hour or day
Bot Protection Blocks
External cron services get blocked by JavaScript challenges
Upgrade Pressure
"Upgrade to premium for cron access" - but you just need one simple task
The CronPop Solution
CronPop runs your code in the cloud, separate from your hosting. Instead of relying on your hosting provider's cron, you write PHP scripts that connect to your database or APIs directly. Your hosting never knows the difference.
Common Use Cases
What can you automate when your hosting won't let you?
Query your database for pending emails and send them via Mailjet or SendGrid API
Delete old sessions, expired tokens, or temporary data automatically
Pull data from your database and send daily/weekly summaries
Keep your database in sync with external APIs or services
Step-by-Step: Send Emails from Your Database
The most common request: query a MySQL database and send emails. Here's exactly how to do it.
Get 100 free executions to test this
Step 1: Get Your Database Connection Details
Find these in your hosting control panel (cPanel, hPanel, or custom dashboard):
Step 2: Get an Email API Key
Free hosting usually blocks the PHP mail() function. Use an email API instead - they're more reliable anyway.
Recommended: Mailjet (Free tier: 6,000 emails/month)
- Sign up at mailjet.com
- Go to Account Settings ā API Keys
- Copy your API Key and Secret Key
Alternative: SendGrid (Free tier: 100 emails/day)
- Sign up at sendgrid.com
- Go to Settings ā API Keys ā Create API Key
- Copy your API key
Step 3: Create Your CronPop Job
Here's a complete script that queries your database and sends emails via Mailjet:
<?php
// Database connection (use YOUR hosting's external MySQL hostname)
$host = 'sql123.infinityfree.com'; // NOT localhost!
$db = 'if0_12345678_myapp';
$user = 'if0_12345678';
$pass = 'your_db_password';
// Mailjet API credentials
$MJ_API_KEY = 'your_mailjet_api_key';
$MJ_SECRET = 'your_mailjet_secret';
try {
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected to database\n";
// Query for pending emails (adjust to your table structure)
$stmt = $pdo->query("
SELECT id, recipient_email, subject, body
FROM email_queue
WHERE sent_at IS NULL
LIMIT 10
");
$emails = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "Found " . count($emails) . " pending emails\n";
foreach ($emails as $email) {
// Send via Mailjet API
$data = [
'Messages' => [[
'From' => ['Email' => 'noreply@yourdomain.com', 'Name' => 'Your App'],
'To' => [['Email' => $email['recipient_email']]],
'Subject' => $email['subject'],
'HTMLPart' => $email['body']
]]
];
$ch = curl_init('https://api.mailjet.com/v3.1/send');
curl_setopt($ch, CURLOPT_USERPWD, "$MJ_API_KEY:$MJ_SECRET");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
// Mark as sent
$update = $pdo->prepare("UPDATE email_queue SET sent_at = NOW() WHERE id = ?");
$update->execute([$email['id']]);
echo "Sent email to {$email['recipient_email']}\n";
} else {
echo "Failed to send to {$email['recipient_email']}: $response\n";
}
}
echo "Done!\n";
} catch (PDOException $e) {
echo "Database error: " . $e->getMessage() . "\n";
}
More Examples
šļø Clean Up Old Database Records
<?php
// Connect to your database
$pdo = new PDO(
"mysql:host=sql123.infinityfree.com;dbname=if0_12345678_myapp",
"if0_12345678",
"your_password"
);
// Delete sessions older than 24 hours
$stmt = $pdo->prepare("DELETE FROM sessions WHERE created_at < DATE_SUB(NOW(), INTERVAL 24 HOUR)");
$stmt->execute();
echo "Deleted " . $stmt->rowCount() . " old sessions\n";
// Delete unverified accounts older than 7 days
$stmt = $pdo->prepare("DELETE FROM users WHERE verified = 0 AND created_at < DATE_SUB(NOW(), INTERVAL 7 DAY)");
$stmt->execute();
echo "Deleted " . $stmt->rowCount() . " unverified accounts\n";
echo "Cleanup complete!\n";
š Daily Stats Report to Slack
<?php
$pdo = new PDO(
"mysql:host=sql123.infinityfree.com;dbname=if0_12345678_myapp",
"if0_12345678",
"your_password"
);
// Get yesterday's stats
$stats = $pdo->query("
SELECT
COUNT(*) as new_users,
(SELECT COUNT(*) FROM orders WHERE DATE(created_at) = CURDATE() - INTERVAL 1 DAY) as orders
FROM users
WHERE DATE(created_at) = CURDATE() - INTERVAL 1 DAY
")->fetch(PDO::FETCH_ASSOC);
// Send to Slack
$message = "š Daily Stats:\n⢠New users: {$stats['new_users']}\n⢠Orders: {$stats['orders']}";
$ch = curl_init('https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['text' => $message]));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
echo "Stats sent to Slack!\n";
Hosting-Specific Tips
InfinityFree / iFastNet
- External MySQL hostname:
sqlXXX.infinityfree.com(find in control panel) - Remote MySQL must be enabled in your control panel
- Bot protection will block simple HTTP cron services - PHP scripts bypass this
000webhost
- MySQL hostname for external connections varies - check your dashboard
- Free tier has sleep hours - your DB may be unreachable at night
Hostinger Free / Budget Plans
- External MySQL access may need to be enabled in hPanel
- You may need to whitelist CronPop's IP range (contact support if needed)
PHP Environment
Finally, Cron Jobs That Work
Stop fighting with your hosting provider's limitations. CronPop lets you run scheduled tasks exactly when you need them, connecting to any database or API.
Bypass Restrictions
Works even when your hosting blocks cron
Connect Anywhere
MySQL, PostgreSQL, APIs, webhooks
Reliable Email
Send via API, not blocked mail()
Stay on Free Hosting
No need to upgrade just for cron
Questions?
If your hosting allows external MySQL connections (most do), yes. CronPop connects directly to your database - your hosting provider isn't involved in running the cron.
Free to start with 100 credits. Then 1 credit per execution. Running every 5 minutes costs ~8640 credits/month (~9€).
Your scripts are private and encrypted. We recommend creating a dedicated database user with only the permissions your script needs.
Enable email notifications and we'll alert you immediately when something goes wrong. Full logs are available in your dashboard.