Automating Permissions and Cache issues in mautic

From time to time there are somethings which mautic always seems to have an issue with. One of these is the mautic cache environment. This seems to break after an update or sometimes when new plugins / themes are added.

Why does this happen?

When there are updates to the software the assets need to be re-cached to allow everything to function correctly again. There are more complex reasons for this but we are not going to spend time on this.

We have a small script which we run as a cronjob which solves most of these issues.

How it works

  1. The script Clears the Cache (2 command options)
  2. Sets the correct permissions and ownership on various files and folders
  3. Starts the Cache Warmup
  4. Re-generates the mautic assets

Setting this as a cronjob has also saved us issues where mautic sometimes gets stuck. We generally run this script once a day, when its not so busy.

You can get the full script from this link.