PHP cron jobs let you run a script automatically on a schedule, without waiting for someone to visit your website. In cPanel, you set the timing and provide the command that starts the PHP script.

The setup is straightforward once you have the right script path and PHP command. We'll walk through each part, including how to handle WordPress tasks and what to do when a scheduled job doesn't run.

What PHP cron jobs do

A cron job is a server task that runs at a time or interval you define. cPanel's Cron Jobs tool lets you set that schedule and enter the command the server should run. The command can start a PHP script for work such as processing a data file or performing a routine maintenance task.

A person's hands resting on a wooden desk next to a small notepad with a grid pattern.

Timing and commands are separate

Think of the job as two parts: when it runs and what it runs. The timing fields tell the server when to start. The command tells it which PHP executable and script to use.

That distinction makes troubleshooting easier. If the schedule is correct but the script path is wrong, the task still won't do its work. If the command works but the timing is off, it may run at an unexpected time. cPanel's Cron Jobs documentation describes cron as scheduled tasks that run at predefined times or intervals.

Cron runs on the server

A cron job doesn't need a browser visit to trigger it. The server starts the command according to its schedule, which makes cron useful for tasks that should happen independently of site traffic.

This is different from a button or link on a web page. You're not asking a visitor's browser to open a PHP file. You're asking the server to run that file through PHP's command-line interface.

Prepare your PHP script before scheduling it

Start with a script that already works and has a clear purpose. A cron job can run automatically, but it can't fix missing files, application errors, or a PHP setup that doesn't meet the script's requirements.

Know where the script lives

Find the script's location in cPanel File Manager or through your usual file transfer method. For a domain, the correct folder depends on its document root. The main domain often uses public_html, but add-on domains and other setups can use a different directory.

Keep the script's role clear. A task that imports a file, for example, should point to the import script, not to the site's home page. If your PHP application is still being set up, our guide to hosting a PHP application with cPanel covers the basics of placing files and preparing the PHP environment.

Match the script to its PHP environment

A script may require a particular PHP version, extension, or loader. The PHP version used for command-line tasks can differ from the one assigned to a website, depending on the hosting setup.

Before creating a schedule, understand what the script needs and which PHP runtime it should use. That small bit of preparation prevents a common headache: the site works in a browser, but the cron command fails because it runs under a different PHP environment.

Add a scheduled task in cPanel

Open Cron Jobs in your cPanel account. The interface lets you enter a schedule and a command. Some cPanel versions also offer common schedule choices, while others present the timing fields directly.

Choose when the task should run

The schedule fields represent the minute, hour, day of the month, month, and day of the week. Set each field to match the task's needs. A daily report, for instance, needs a different schedule from a task that should run more frequently.

Keep the interval reasonable. A task that takes time to finish should not be scheduled so often that another run may start before the previous one completes. For your first setup, choose a schedule that gives you time to observe the result before increasing how often it runs.

Enter the command and save

Place the command in the command field, then save the cron job. That command needs to identify both the PHP command-line executable and the script file. Use the full path to the script rather than relying on the server to guess its location.

cPanel's documentation includes an example that uses an absolute path to a script in public_html. The exact paths vary by server, so use the PHP CLI path and script location that apply to your hosting account. The cPanel absolute-path example shows why the complete script path matters.

Build the right command for PHP

The command is the part that connects your schedule to the script. A correct schedule paired with an incomplete or incorrect command won't produce the result you want.

A clean aisle between server racks in a data center with a console in the background.

Use the command-line version of PHP

A cron job should run PHP through the server's command-line interface, or CLI. PHP's CLI runs scripts from the command line rather than handling a page request from a browser. The PHP command-line manual explains how PHP supports this mode.

Don't assume that typing php will always work in the command field. Some hosting environments need the full path to the PHP executable. The right path depends on the server, so use the one provided for your account rather than copying a command from an unrelated tutorial.

Give the script its full path

The script path should identify the file from the server's point of view. A short filename such as task.php may work in one context and fail in another if the command starts from a different directory.

Use the absolute path to the PHP script, and make sure it points to the correct domain folder. Avoid entering a web address in place of the file path. Cron runs a server command, not a browser request. If you're unsure which PHP executable belongs in the command, your hosting provider can tell you the correct path for the account.

Use server cron carefully with WordPress

WordPress has its own scheduling system called WP-Cron. It checks for due tasks during site activity, so scheduled work may not happen at a fixed server time on a low-traffic site. A server cron can be used to trigger WordPress tasks on a schedule, but the setup must match the WordPress configuration.

Don't disable WP-Cron without a replacement

The DISABLE_WP_CRON setting in wp-config.php turns off WordPress's normal scheduling trigger. That setting only makes sense when a server cron has been configured to call wp-cron.php. Without that replacement, scheduled posts and plugin tasks won't run automatically.

If posts are missing their scheduled times, the cause may be WordPress scheduling rather than a standalone PHP script. Our guide to troubleshooting WordPress scheduled posts covers common checks for missed publishing.

Check store tasks as well as posts

WooCommerce and its extensions can use scheduled actions for background work. WP-CLI, when available, includes commands to test cron and run events that are due. WordPress plugins such as WP Crontrol can also help you view or trigger scheduled events.

If a due event works when triggered manually but not on its own, look at how WordPress cron is being triggered. For store-specific issues, see our guide to managing WooCommerce background tasks. Avoid disabling WordPress's built-in trigger until a replacement is in place.

Test the job and troubleshoot calmly

Saving a cron job is only the first step. You also want to know that it runs the intended script, at the intended time, with the expected result.

Test the command before relying on its schedule

When terminal access is available, run the command manually before you depend on the scheduled task. This helps separate a command problem from a timing problem. If you don't have terminal access, start with a simple, low-risk script and check whether it completes its intended task after the scheduled run.

For a script that changes important data, test it carefully before allowing it to run unattended. Confirm the script's target and purpose first. A typo in a command can send the job to the wrong file, while a typo inside the script can affect the wrong data.

Check the schedule and paths when it fails

If nothing happens, review the job's timing fields and both paths in the command. Confirm the PHP executable is the CLI version, and confirm the script path points to the file you intend to run.

Also consider whether the script needs a PHP version or extension that isn't available in the command-line environment. A page loading correctly in a browser doesn't prove that the cron command uses the same PHP configuration. Change one thing at a time, then test again so you know which adjustment fixed the problem.

Choose hosting that fits the work

Scheduled tasks use the same hosting environment as the rest of your site. A short maintenance script has different needs from a store task that processes larger jobs or runs frequently. Match your plan to the site's workload, PHP requirements, and the level of support you want.

ZADiC cPanel hosting plans range from $4.99 to $18.99 per month. If you're building a PHP site and want cPanel tools for managing its files and environment, explore our cPanel hosting for PHP applications guide. For sites that need more room as they grow, Web Hosting Plus and VPS hosting are options to consider.

A dependable hosting setup won't replace a correct command, but it gives your website a clear place to run its scheduled work. When cron is part of how your business operates, make sure the hosting resources and support fit the job.

Key takeaways

  • A cPanel cron job needs a schedule and a command that starts the intended PHP script.
  • Use the correct PHP CLI executable and the full path to the script.
  • Test the command and confirm the task's result before relying on it.
  • WordPress's DISABLE_WP_CRON setting requires a replacement server cron to keep scheduled events running.
  • Choose hosting that matches your site's PHP needs and scheduled workload.

Frequently asked questions

Can cPanel run a PHP script on a schedule?

Yes. Use cPanel's Cron Jobs tool to set when a task runs and enter the command that starts the PHP script. The command needs the appropriate PHP CLI executable and the script's full path.

Does a cron job need website visitors?

No. A server cron runs on its schedule without waiting for a visitor to load a page. That's one difference between a server cron and WordPress's default WP-Cron trigger, which checks for due tasks during site activity.

Why does a PHP script work in a browser but fail as a cron job?

The browser and cron may use different PHP runtimes, configurations, or file paths. Check that the command uses the right PHP CLI executable, points to the correct script, and matches the script's PHP requirements.

Can I use cPanel cron for WordPress?

Yes, a server cron can trigger WordPress scheduled work. If you disable WP-Cron in wp-config.php, configure a replacement that calls wp-cron.php; otherwise WordPress scheduled events may stop running automatically.

Keep scheduled PHP tasks dependable

A scheduled script becomes dependable when its timing, PHP command, and full file path all line up. Set up one job, test the result, and make changes carefully when something doesn't run.

With the right cPanel setup and hosting for your workload, PHP cron jobs can handle routine tasks while you focus on the site itself.

We use cookies so you can have a great experience on our website. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://zadic.net.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings