How to run artisan command schedule:run on hosting server? (Laravel)

How to run artisan command schedule:run on hosting server? (Laravel)

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Why php artisan schedule:run Fails on Shared Hosting

Running a local Laravel application and deploying it to shared hosting involves significant environment shifts. On XAMPP or WAMP, you execute php artisan schedule:run directly from your terminal. This works because the PHP process has direct access to your project files, the correct php.ini, and sufficient system permissions. However, moving to a cPanel shared hosting environment changes the execution context entirely. The command php /path/to/artisan schedule:run often fails not because of a logic error in your code, but due to how the server interprets file paths, user permissions, and process management.

Path Resolution and Working Directory

The most common failure point on shared hosting is the working directory. When you run php /path/to/artisan schedule:run directly from cPanel's File Manager or a command line, PHP executes with the current working directory set to wherever that command was initiated. If your script relies on relative paths for configuration files, environment variables, or database connections, it may fail silently or throw errors.

Furthermore, the schedule:run command expects specific file permissions. The web server user (often nobody, _www, or apache) must be able to read and execute the artisan file and any queued jobs. If you uploaded your project via FTP with restrictive permissions, the cron job might lack the necessary rights to write logs or access temporary files. Ensure that the directory containing your project is writable by the web server user and that the storage and bootstrap/cache folders have 775 or 777 permissions temporarily to test execution.

CRON Job Configuration in cPanel

The command you provided, php /path/to/artisan schedule:run, is correct for a standalone execution, but it lacks the context required by Laravel's scheduler. The scheduler relies on the application environment being fully initialized before running tasks. On shared hosting, simply pointing to the artisan file isn't enough; you must ensure the PHP version selected in cPanel matches the one your composer.json requires.

When setting up a CRON job in cPanel, avoid running the command directly from the root directory unless it is an absolute path. Instead, specify the full path to the artisan file and ensure the cron environment variables match your local setup. For example:

php /home/username/public_html/project/artisan schedule:run >> /dev/null 2>&1

Redirecting output (>> /dev/null 2>&1) is standard for automation to prevent email spam, but this can hide critical errors. If the job stops updating your jobs table, check the cPanel CRON logs or enable logging by appending a log file instead of discarding the output. This helps identify if the process is timing out due to long-running tasks or permission issues.

Environment Variables and Configuration

Your local environment likely loads .env variables correctly because you are running in an interactive shell. On shared hosting, the .env file might not be loaded if the PHP version or APP_ENV variable isn't set correctly at runtime. Ensure that your config/app.php has the correct cache driver and that your database credentials are accessible to the web server user.

Additionally, check if your statusUpdate command is actually being registered in Kernel.php. The line \App\Console\Commands\statusUpdate::class must be present in the $commands array. If you are using the newer Laravel scheduling syntax, ensure that the schedule definition uses the correct signature:

protected function schedule(Schedule $schedule)
{
    $schedule->command('status:update')->hourly(); // Or everyFiveMinutes() for older versions
}

Debugging Execution Failures

If the cron job runs but your database jobs table does not update, verify that the command signature and handler are correct. The handle() method should return a value or throw an exception if something goes wrong. On shared hosting, memory limits are often lower than on local machines. If your update logic takes too long or processes too many rows at once, PHP might hit its memory ceiling and kill the process.

Consider breaking down large updates into smaller batches to avoid timeout issues. Also, ensure that the DB facade is correctly configured in your config/database.php file for the shared hosting environment, as some hosts require specific PDO drivers or socket configurations. If all else fails, test the command manually via SSH with verbose output:

php /path/to/artisan schedule:run --verbose

This will reveal any errors that are otherwise hidden during automated execution.

Our network