automate a safe wordpress update through a cron job

I’m a great believer in automation; as one of my interviewers said to me once: If we do it twice; we automate it.
I adopted this style throughout my work; hence I wanted to show how would I upgrade/update the WordPress core and plugins using cron to keep all my blogs and sites secure and up to date with security patches.

1- get & install wp-cli (how/where)
2- write a script to use wp-cli to update WordPress [see attached code]

 

3- add that script to your crontap using the crontab -e command; you can use http://crontab-generator.org to generate one if you’re not familiar with the syntax
I have my cron running this script each mid month

my real working version is slightly different; for example I like to do a health check after an update to check if my server is down.
You may not want to auto-update if you run complex stuff; I don’t know it’s up to you to tweak it 🙂

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.