Is there any way to run one file and fire multiple magento2 command like Index, static content, deploy, cache clear etc. And for all files permissions set Automatically.

  • 2
    May be you are looking for Script file
    – Nero Phung
    Dec 18, 2017 at 7:22
  • 1
    Yes That what i am looking for @NeroPhung
    – Jaimin
    Dec 18, 2017 at 7:23
  • 1
    Nice, hope it help you @Jaimin
    – Nero Phung
    Dec 18, 2017 at 7:34

1 Answer 1


If you are using a Linux system, then you can create commands.sh file and put all this code.

rm -rf var/cache/ var/page_cache/ var/view_preprocessed/ pub/static/frontend/ pub/static/adminhtml/
php -dmemory_limit=8G bin/magento cache:clean
php -dmemory_limit=8G bin/magento cache:flush
php -dmemory_limit=8G bin/magento catalog:images:resize
php -dmemory_limit=8G bin/magento setup:upgrade
php -dmemory_limit=8G bin/magento setup:di:compile
php -dmemory_limit=8G bin/magento indexer:reset
php -dmemory_limit=8G bin/magento indexer:reindex
php -dmemory_limit=8G bin/magento setup:static-content:deploy -f
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
  • i wonder if someone already copied this an run on his setup...
    – MagenX
    May 19, 2019 at 9:36
  • I run some of the above commands on my local system. you can suggest your review if I wrote the wrong answer. May 19, 2019 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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