Created
April 1, 2019 09:07
-
-
Save dgpro/ced054777b2811399bef891aa49a34ec to your computer and use it in GitHub Desktop.
SSH Script to automatically run a number of commands on remote servers. E.g. to restart Laravel instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# exit if any of the commands fail | |
set -e | |
# import config with IP addresses | |
source ${BASH_SOURCE[0]%/*}/ip.conf | |
echo -e "Connecting to IP:$laravel"; | |
ssh root@$worker -t "cd /var/www/ && | |
php artisan down && | |
php artisan config:cache && | |
sudo service php7.1-fpm restart && | |
php artisan up" | |
# can repeat for multiple servers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment