Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2785  / 1 Year ago, thu, may 4, 2023, 12:11:39

I have a really simple bash script with 5 commands running under the root user. If I run commands manually one by one everything works - no problem. But as I run it as my-deploy.sh file via command


bash /root/custom-scripts/deploy/my-deploy.sh 2>> /var/log/www-deploy/tatrytec.eu.log

it seems like endless process. Here is the script:


#!/bin/bash
# Run this script as bash command like: bash create-apache-site.sh

cd /var/www/html/tatrytec.eu

git pull

# Change user bacause of composer install warrning
su vlado

composer install --no-scripts

npm install --production

It starts to run and I can see result of git pull in terminal. But then it dies without any error and it is still running. I can stop it via ctrl+Y. I thing something is wrong with that user but as I wrote before if I run commands one by one it works. I dont understand. Can somebody tell me what could be the problem? Thanks.


More From » bash

 Answers
5

You seem to want to run the last lines in your script as the user vlado. There is a clean way to do that:


sudo -u vlado  your_command 

So the last few lines of your script will look like this:


sudo -u vlado composer install --no-scripts
sudo -u vlado npm install --production

[#1978] Friday, May 5, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bearous

Total Points: 226
Total Questions: 116
Total Answers: 136

Location: Guernsey
Member since Sun, Jan 10, 2021
3 Years ago
;