🎉🎉 Larasense is officially launched 🎉🎉
- Your Hub for Laravel News, Trends & Updates

Add Laravel Scheduler Command to Crontab on Ubuntu

laravel
scheduler
tutorial
Nabil Hassen
Nabil Hassen
Sep 25, 2025
Add Laravel Scheduler Command to Crontab on Ubuntu
Last updated on Sep 25, 2025
Table of contents:

How to Add the Laravel Scheduler Command to Crontab (on Ubuntu)

When building Laravel applications, many background tasks (e.g. cleanup jobs, sending queued emails, recurring reports) are best managed via Laravel’s built‑in scheduler. But to make the scheduler run automatically, you need to hook it into the system cron on your server. In this post, I’ll walk through how to do that on Ubuntu.

Prerequisites & assumptions

Before proceeding, this guide assumes:

  • You already have a working Laravel project on Ubuntu (e.g. in /var/www/… or some directory).
  • You have shell / SSH access with sudo (or at least enough rights to edit crontab for a user).
  • cron service is installed or can be installed.
  • PHP CLI is accessible from the command line (e.g. php works).

Step 1: Update & (if needed) install cron

It’s good practice to ensure your system is up to date, and to confirm cron is installed and running.

sudo apt-get update
sudo apt-get upgrade

Then install cron if it’s not already:

sudo apt-get install cron

After installation, check the status:

systemctl status cron

You should see something like “active (running)”. If it's not running, you may start it:

sudo systemctl enable cron
sudo systemctl start cron

Step 2: Edit the crontab

To schedule Laravel’s scheduler, you’ll add a cron entry that runs every minute. Usually you won’t need to touch the system /etc/crontab (unless you're root or managing many users). Instead, edit the crontab for the relevant user (often the same user under which your web server or application runs).

Run:

crontab -e

If it’s your first time doing this, it may prompt you to choose an editor (like nano, vim, etc.).

In the crontab file, add this line:

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Make sure to replace /path-to-your-project with your actual path (for example, /var/www/html/your-laravel-app).

After editing, save and exit. Cron will pick up the change automatically.

Common pitfalls & tips

Issue Description / Fix
Wrong path If cd points to a non-existent directory, cron will fail silently. Double-check absolute path.
Wrong PHP binary Sometimes the CLI PHP version is different or not in $PATH. Use full path (e.g. /usr/bin/php).
Permissions & ownership Ensure the user whose crontab you edit has permissions to run the commands and access project files.
Output flooding / emails Without redirecting output, cron may send an email on every run. That’s why we use >> /dev/null 2>&1.
Multiple crontab entries If you already have a cron for the same user, ensure this new line doesn’t conflict.

Conclusion

Integrating Laravel’s scheduler with the system cron is a simple but essential step. Once it’s configured, your application can reliably run scheduled jobs without manual intervention. Just:

  1. Install/verify cron on Ubuntu
  2. Add a cron entry (via crontab -e) to run php artisan schedule:run every minute
  3. Verify everything works
Nabil Hassen
Nabil Hassen
Full Stack Web Developer

Stay Updated.

I'll you email you as soon as new, fresh content is published.

Thanks for subscribing to my blog.

Latest Posts