Search code examples
laravelcronforge

How do I configure automatic security updates with Laravel Forge's Scheduler?


Every week I ssh into my server and run:

sudo apt update
sudo apt upgrade

How can I use Laravel Forge scheduler to run these commands properly to install security updates?

From my understanding I would schedule a job with the following command:

sudo apt-get update && sudo apt-get -y upgrade

Is this correct and doing what I expect it be doing?

Example of a command


Solution

  • php /home/forge/default/artisan scheduled:run
    

    Now in Laravel, I can see that I can add jobs in the kernel.php file eg:

    
    protected function schedule(Schedule $schedule)
        {
            $schedule->command('sudo apt-get update && sudo apt-get -y upgrade')
                   ->weekly();
        }
    

    Also Check link Laravel's Scheduler docs - https://laravel.com/docs/5.1/scheduling#introduction