Skip to main content

Command Palette

Search for a command to run...

Set up Cron Job on a Ubuntu Server.

Published
M

My name is Md Muhaiminul Islam Shihab, I'm a passionate software developer specializing in HTML, CSS, Bootstrap, Tailwind CSS, jQuery, JavaScript, Vue.js, Nuxt.js, React.js, Next.js, React Native, PHP, Laravel, Livewire, Filament PHP, MySQL, and PostgreSQL. With over three years of dedicated expertise, I have worked in various fields, including web design and development, software development, and database design and optimization. I am always excited to explore new tools and technologies.

  1. Open the Crontab File:

    Open the crontab file for the user under which your Laravel application runs. Typically, this would be your web server user. For example, if you're using Apache, the user might be www-data. Use the following command to edit the crontab file for that user:

     sudo crontab -u www-data -e
    
  2. Add a Cron Job for Laravel Scheduler:

    Add the following line to the crontab file. This command will run Laravel's scheduler every minute:

     * * * * * cd /path/to/your/laravel && php artisan schedule:run >> /dev/null 2>&1
    
  3. Save and Close the Crontab File:

    Save and close the crontab file. If you're using nano as the default text editor, you can save and exit by pressing Ctrl + X, then Y, and finally Enter.

  4. Verify the Cron Job:

    After saving the crontab file, you can verify that the cron job has been added correctly by listing the current crontab entries:

     sudo crontab -u www-data -l
    
  5. Check the Laravel Logs:

    After a few minutes, you can check the Laravel logs to ensure the scheduled tasks are executed as expected. The scheduler's output will be logged in Laravel's default log file, usually located at storage/logs/laravel.log.

More from this blog

জনপ্রিয় ডিজাইন প্যাটার্নস বাংলায়

ডিজাইন প্যাটার্ন হলো পুনরায় ব্যবহারযোগ্য সমাধান যা সফটওয়্যার ডিজাইনের সাধারণ সমস্যাগুলো সমাধানে ব্যবহৃত পদ্ধতি। এগুলো ব্যবহার করে কোডকে আরও সহজ, মেইনটেনেবল এবং এক্সটেন্ডেবল করা যায়। নিচে কিছু জনপ্রিয় ডিজাইন প্যাটার্নের বাংলা ব্যাখ্যা এবং কোড উদাহ...

Oct 19, 20247

বাংলায় Solid ডিজাইন প্রিন্সিপালস

SOLID ডিজাইন প্রিন্সিপালস হলো ৫টি ডিজাইন নীতির সমষ্টি যা অবজেক্ট-ওরিয়েন্টেড প্রোগ্রামিং (OOP) এ ভালো কোড করার নিয়ম হিসেবে বিবেচিত। এগুলোর উদ্দেশ্য হলো কোডকে সহজে বোধগম্য, মডিফাই এবং মেইনটেইন করা। নিচে প্রতিটি প্রিন্সিপাল এর বাংলা ব্যাখ্যা এবং কোড উ...

Oct 19, 202422
বাংলায় Solid ডিজাইন প্রিন্সিপালস

Muhaimin Shihab's Blog

9 posts

In this blog, I’ll share my technical knowledge, daily experiences, and challenges as a software developer.