I have a BASH script which runs other commands and I would like to keep them running in case the main script stops. I tried to run those commands with & but it didn’t help. Am I doing something wrong?
I have a BASH script which runs other commands and I would like to
Share
This is normal: the shell’s job control mechanism terminates its jobs when it exits.
There are at least two solutions:
disownafter you have launched a job;atto schedule your job at a later time;nohupcommand.Now, there is the question of what you want to do with the output of the command you launch in the background:
disown, you lose it;at, stdout and stderr are sent to you by mail (but then you can redirect stdout/stderr if you want);nohup, you define the output file yourself.