1

Is it possible to automatically apply Craft CMS updates when they become available?

At the moment, I have to go into the CPanel and apply updates with the one-click option.

Maybe I can do this with a cron job?

2

Of course you can, but it's going to be a little bit tricky since you have to be logged in or you have to find a way how to login with an automatic request. Like others said, it's a dangerous things and I would not suggest to auto update since something can eventually break and you'll not notice it before your customers.

What you can do is

  1. Create a controller that uses the user service to login with admin credentials
  2. Redirect to admin/updates/go/craft <- this will start the update

Making an update for Craft 2 is actually just visiting the admin/updates/go/craft everything else is automatic

  • I agree with you both that it's bad practice. I want to experiment with this within a staging environment :) – Sam Jan 12 '18 at 17:03
  • Alright, if it's only for staging servers it might be ok. If you are not able to create an auto login I can provide one. I'm currently on my smartphone so it's a little bit tricky to write code but it requires actually all in all only about 10-15 lines because craft has many ready to use functions for that – Robin Schambach Jan 12 '18 at 17:12
2

It's typically bad practice to allow auto-updates -- at least in a production environment.

That being said, to update Craft, you're required to download the new files (click "Download" on the update page and it gives you a zip file), and then replace them in your codebase. So right now, no you wouldn't be able to do this with a Cron Job.

Craft 3 may be a different story, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.