Docs / Cron & worker

Cron & worker

Heavy rendering runs in a background worker, never in the web request. On capable servers a visit can spawn it; on shared hosting you point a system cron at it for reliability.

The render worker

When a user generates a video, a job is queued. The worker (cron/worker.php) claims queued jobs one at a time and renders them with FFmpeg + the AI providers. It is safe to run continuously or on a schedule — jobs are claimed atomically so two workers never pick the same job.

Hybrid model: on servers that allow it, a page visit spawns the worker in the background, so renders start immediately even without a system cron. Adding a real cron makes it reliable on every host.

Recommended cron jobs

In cPanel (or crontab -e), add the render worker every minute:

# Render worker — every minute (also reclaims jobs from crashed workers)
* * * * * /usr/bin/php /path/to/tokify/cron/worker.php >/dev/null 2>&1

Use the absolute path to PHP your host provides (often /usr/local/bin/php or a versioned binary such as /usr/bin/php8.4).

Scheduled tasks

Beyond rendering, Tokify has a lightweight scheduler that publishes due social posts, runs the daily update check and performs housekeeping. These run automatically after each site visit, so a site with normal traffic needs nothing extra.

If your site can sit idle for long stretches and you rely on scheduled posting, add a second cron that simply pings the homepage so the scheduler ticks even with no visitors:

# Keep the scheduler ticking when there is no traffic — every 5 minutes
*/5 * * * * /usr/bin/curl -s https://your-domain/ >/dev/null 2>&1

Long renders

Avatar renders can take minutes while the provider works. The worker disables the time limit and ignores client disconnects, persists progress so the UI shows live %, and does not retry money-spending steps on terminal errors (so a failed avatar render is never double-charged).

No cron at all? Renders still start on visits, but a job queued while nobody is browsing waits until the next visit. For production, always add the worker cron.
Tokify · © 2026 Medel Platforms · medel.es