The main script has a background task executing test1.sh, i am trying to stop the background task when the main task also completes
#!/bin/sh
# background process
./test1.sh &
# do while starts
x=1
while [ $x -le 30 ]
do
echo "Welcome $x times "
x=$(( $x + 1 ))
sleep 1
done
exit
The ./test1.sh file contains
#!/bin/sh
while true
do
echo "copying "
cp logs.txt /tmp
sleep 10
done
Or any best approach to run the background task in a separate thread of copying files and exit after the main task completes