AdminsForum

CyberPanel Websites & OpenLiteSpeed Guides

Guide CyberPanel Cron Jobs: Add a Cron Job and Replace WP-Cron With a Real One

Started by JAY 0 replies 96 views
1JAY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
CyberPanel Cron Jobs: Add a Cron Job and Replace WP-Cron With a Real One

A cron job runs a command on a schedule: a backup script every night, a Laravel scheduler every minute, a WordPress task runner every five minutes. CyberPanel has a page for this per website, so you don't need to open crontab by hand. Below we add a real job on our test site and use it for the most common case: replacing WordPress's built-in WP-Cron.

Where to find it
Open Websites > List Websites, click Manage on your site and find Cron Jobs. The direct address is:
Code:
https://YOUR-SERVER-IP:8090/websites/listCron?domain=yourdomain.com
Each website has its own list. The jobs run as that website's Linux user (ours is
Code:
cyber2602
), not as root. That's good for security, and it means the files your job creates belong to the site, so WordPress can still edit them.

Step 1: Fill in the schedule
The Pre defined dropdown fills the five time fields for you: every minute, every 5 minutes, every 30 minutes, every hour, every day, every week, every month, every year. Pick one, or type your own values:
  • Minute 0-59, Hour 0-23, Day of month 1-31, Month 1-12, Day of week 0-6 (0 = Sunday).
  • Code:
    *
    means "every".
    Code:
    */5
    means "every 5th".
    Code:
    1,15
    is a list,
    Code:
    1-5
    is a range.
  • Examples:
    Code:
    0 3 * * *
    = 03:00 every day.
    Code:
    30 2 * * 0
    = 02:30 every Sunday.
    Code:
    0 */6 * * *
    = every 6 hours.
The time is the server's time zone. Check it with
Code:
timedatectl
; ours was UTC.

Step 2: The command (use the full PHP path)
Here is the form filled in for WordPress, with the Every 5 minutes preset:
[Image: attachment.php?aid=488]

The field hint says
Code:
/usr/bin/php /path/to/script.php
. On our server
Code:
/usr/bin/php
is a link to PHP 8.3:
Code:
ls -l /usr/bin/php /usr/bin/php -> /usr/local/lsws/lsphp83/bin/php
That's fine until your site uses a different PHP version than the server default. To be sure the job runs with the same PHP as the website, write the full path of that version:
Code:
/usr/local/lsws/lsphp81/bin/php
,
Code:
/usr/local/lsws/lsphp82/bin/php
,
Code:
/usr/local/lsws/lsphp83/bin/php
and so on. See which ones you have with
Code:
ls /usr/local/lsws/ | grep lsphp
.

Our WordPress command:
Code:
/usr/local/lsws/lsphp83/bin/php /home/cyber.adminslab.com/public_html/wp-cron.php >/dev/null 2>&1
Code:
>/dev/null 2>&1
throws the output away. Without it, cron tries to email the output to the site user every run.

Step 3: Save and check
Click Add Cron, then Fetch Current Cron Jobs. The new job shows up with edit and delete buttons:
[Image: attachment.php?aid=489]

CyberPanel writes the job into the site user's crontab. You can see the same thing from SSH:
Code:
crontab -u cyber2602 -l */5 * * * * /usr/local/lsws/lsphp83/bin/php /home/cyber.adminslab.com/public_html/wp-cron.php >/dev/null 2>&1
Before we added it, the same command said
Code:
no crontab for cyber2602
. Replace
Code:
cyber2602
with your site's user (the owner of
Code:
public_html
:
Code:
stat -c %U /home/yourdomain.com/public_html
).

To change a job, use the edit (pencil) button; to remove it, the delete button. If the list looks empty, click Fetch Current Cron Jobs: the page doesn't always load them on its own.

Step 4: Turn off the built-in WP-Cron
By default WordPress runs its scheduled tasks (publishing scheduled posts, plugin update checks, LiteSpeed Cache image optimization, WooCommerce jobs) when a visitor opens a page. On a quiet site tasks run late; on a busy site the check runs on every page view. With a real cron in place, switch the visitor trigger off:
Code:
cd /home/yourdomain.com/public_html sudo -u cyber2602 wp config set DISABLE_WP_CRON true --raw
WP-CLI answered
Code:
Success: Added the constant 'DISABLE_WP_CRON' to the 'wp-config.php' file with the raw value 'true'.
(No WP-CLI yet? See our WordPress install guide. Or add
Code:
define( 'DISABLE_WP_CRON', true );
to
Code:
wp-config.php
above the "That's all, stop editing" line with the File Manager.)

Do step 3 before step 4. If you disable WP-Cron without a server cron, scheduled posts and plugin tasks silently stop.

Step 5: Prove it works
List WordPress's queued tasks:
Code:
sudo -u cyber2602 wp cron event list --fields=hook,next_run_relative
Right after we disabled WP-Cron, two tasks were overdue and showed
Code:
now
:
Code:
wp_update_plugins
and
Code:
litespeed_task_lqip
. To see cron start the job, check the system log:
Code:
journalctl -u cron --since "-15min" --no-pager | grep cyber2602
Every five minutes the log shows a session opening for the site user and the command it ran:
[Image: attachment.php?aid=529]

To test the command without waiting, run it by hand as the site user, then list the tasks again:
Code:
sudo -u cyber2602 /usr/local/lsws/lsphp83/bin/php wp-cron.php; echo EXIT=$? sudo -u cyber2602 wp cron event list --fields=hook,next_run_relative
Ours printed
Code:
EXIT=0
, and the overdue tasks were gone:
Code:
wp_update_plugins
had run, and
Code:
litespeed_task_lqip
moved to its next slot. No output and exit code 0 is what success looks like; a PHP error here is the same error your cron job hits.

Other jobs people add
  • Laravel scheduler, every minute:
    Code:
    cd /home/yourdomain.com/public_html && /usr/local/lsws/lsphp83/bin/php artisan schedule:run >/dev/null 2>&1
  • Open a URL (some apps give you a cron URL):
    Code:
    curl -fsS https://yourdomain.com/cron.php >/dev/null 2>&1
  • Keep a log while you test: replace
    Code:
    >/dev/null 2>&1
    with
    Code:
    >> /home/yourdomain.com/cron.log 2>&1
    , then read the file. Switch back when it works so the log doesn't grow forever.
For backups, use CyberPanel's own schedule instead of a hand-made job: see scheduled backups in CyberPanel.

Common problems
  • Job never runs: is cron running?
    Code:
    systemctl is-active cron
    should print
    Code:
    active
    . Then check the log command above.
  • Runs from SSH but not from cron: cron has a tiny PATH. Use full paths for everything: PHP, scripts,
    Code:
    curl
    (
    Code:
    /usr/bin/curl
    ).
  • Permission denied: the job runs as the site user, so it can't write to root-owned folders. Keep scripts and output inside
    Code:
    /home/yourdomain.com/
    .
  • Wrong PHP version or missing extension: use the full
    Code:
    /usr/local/lsws/lsphpXX/bin/php
    path that matches the site.
  • Scheduled posts show "Missed schedule": WP-Cron is disabled but the server job is missing or failing. Run the command by hand as the site user to see the error:
    Code:
    sudo -u cyber2602 /usr/local/lsws/lsphp83/bin/php /home/yourdomain.com/public_html/wp-cron.php

More CyberPanel guides
Tested on CyberPanel 3.0 (build 8, OpenLiteSpeed edition) on Ubuntu 24.04, October 2026. Menu names can change slightly between versions.

Attached Files

Image(s)
           
Reply

Messages In This Thread
CyberPanel Cron Jobs: Add a Cron Job and Replace WP-Cron With a Real One - by JAY - 10-26-2026, 01:39 AM
Possibly Related Threads…matched by title
Replies:0Views:10
Replies:0Views:17
Replies:0Views:18
Replies:0Views:15
Replies:0Views:105

Users browsing this thread: 1 Guest(s)
Forum Jump: