I want to do a bash script with these requirements:
REQUIREMENTS:
The script:
- launches, in parallel, the execution of several processes
- waits for the processes to finish execution before continuing its own execution.
Each process:
takes a relative long time to finish execution
should output its logs to both a child gnome-terminal window and to a log file, which should be different from the terminal windows and log files of the other processes and the terminal window used by the father script.
should not finish even if the user closed the corresponding child gnome-terminal window. That means it should keep on running and outputing logs to its corresponding log file even if the user either closed the child gnome-terminal window or pressed ctrl+c on the child gnome-terminal window.
MY TRY:
I have tried to implement this with the code below:
nohup gnome-terminal --wait -- bash -c "cd /home;find . -name "foo*" | tee /home/$USER/log-home.txt" &
nohup gnome-terminal --wait -- bash -c "cd /home/$USER; find . -name "foo*" | tee /home/$USER/log-$USER.txt" &
wait;
echo "Finished";
The code abgove does not meet the expected requirements though:
- If I close a child gnome-terminal window, the process running within it stops outputing logs to the corresponding log file. I guess this process just finishes running.
- If I close all the child gnome-terminal windows launched from the father script, the father script continues running the script lines after the wait command.