I have a script running in background, like:
su - insite1 -c "invokeTest.sh" &
Now this script, invokeTest.sh has contents:
while [ 1 ] do echo "Hello World from invokeTest" >> /tmp/invokeTest ( exec "/tmp/test.sh" ) done
Although it prints, “Hello World from invokeTest” it does not call test.sh.
My question:
Is there any way to call test.sh in infinite while loop directly from su - insite1 -c" "
so that we can totally skip invokeTest.sh
itself (but test.sh needs to run in background”?
If no, how to make sure test.sh is called from invokeTest.sh
?
Advertisement
Answer
To answer your question about running the command without a script, you can put any shell commands into the -c
argument, including a while
loop. So you can write:
su - insite1 -c 'while :; do echo "Hello World" >> /tmp/invokeTest; /tmp/test.sh; done' &