As I'm sure you'll all tell very soon, I'm no expert when it comes to this sort of thing. However, when trying to look at results, I've not been able to come across anything quite like what I need - so I decided to ask here.
BACKGROUND: When I log into my server, I need to cd into a folder and run some commands based on one of the 3 things I want to do:
1) Stop the server 2) Start the server 3) Rebuild the server
AIM: Rebuilding the server takes 2 commands, one of them (to rebuild) takes some time and instead of me having to cd into the directory, stop the server, rebuild the script, then start it again... I'm trying to create a bash file to do it for me, so I can simply login and execute one command.
The directory I need to CD into is: /var/www/website/
The stop process I need to enter is: pm2 stop 0
The Rebuild process I need to enter is: yarn run build -- --release
The start process I need to enter is: pm2 start build/server.js
When I created a restartserver.sh file, I created it as follows:
#!/bin/bash
cd /var/www/website
pm2 stop 0
yarn run build -- --release
pm2 start build/server.js
When i try to run it by typing 'restartserver.sh' I get the error: -bash: restartserver.sh: command not found
I'm sure this is really easy for someone who has any idea about this sort of thing... but for my... I've no idea. Can anyone please help?
Thanks
P