I am trying to write a simple bash script that should start an other script as another user and in a way that the script
What I have right now:
This is basically how start.sh
looks like
# doing some other stuff
sudo su user_the_script_should_start_as -c "./start-in-background.sh $1 $2 $3"
start-in-background-sh
# doing some other stuff
# Start other Script in Background
How can I do those three points?
You can use
nohup bash your_script.sh &
or
disown bash your_script.sh &
or
screen
But my suggestion is screen
command. Also tumx
is good to use.
And for your last requirement to stop script on call will be able to achieved by following command,
kill $!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.