Other languages / Другие языки / Забонҳои дигар: Русский Тоҷикӣ

Cron is the Linux scheduler that runs commands on schedule: every minute, hour, day etc. Used for backups, cache clearing, newsletters, CMS updates.

How to create a Cron in cPanel:

  1. cPanel → "Advanced" section → Cron Jobs.
  2. Use Common Settings (hourly, daily etc.) or enter manually.
  3. Schedule (5 fields): Minute Hour Day Month Weekday. Examples:
    • * * * * * — every minute.
    • 0 * * * * — every hour at minute 00.
    • 0 3 * * * — every night at 3:00.
    • 0 0 * * 0 — every Sunday at midnight.
  4. Command — what to run. Examples:
    • WordPress cron: php /home/USER/public_html/wp-cron.php
    • Script: cd /home/USER/public_html && php script.php
    • Curl: curl -s https://example.tj/cron.php > /dev/null
  5. Add New Cron Job.

Email notifications:

In the top "Cron Email" field set an address — output (stdout/stderr) of every run goes there. Convenient for debugging. To suppress — add > /dev/null 2>&1 at the end of the command.

Logging:

To preserve output — write to file: php script.php >> /home/USER/cron.log 2>&1.

Bu cevap yeterince yardımcı oldu mu? 0 Bu dökümanı faydalı bulan kullanıcılar: (0 Oy)