You can run the task in the background as follows:
command &
This allows you to run several tasks in a row, without waiting for the end of the previous one.
If you run several background jobs like this, they will all have the same stdout (and stderr ), which means that their output will probably alternate. For example, take the following script:
#!/bin/bash
Run it twice in the background:
./countup.sh & ./countup.sh &
And what you see in your terminal will look something like this:
1 1 2 2 3 3
But it may also look like this:
1 2 1 3 2 3
You probably do not want this, because it would be very difficult to figure out which solution belongs to the task. Decision? Redirecting stdout (and optionally stderr ) for each job to a separate file. for instance
command > file &
will only redirect stdout and
command > file 2>&1 &
will redirect both stdout and stderr for command to file when running command in the background. This page provides a good introduction to redirection in Bash. You can view the output of the "live" command with the tail file:
tail -f file
I would recommend running background jobs using nohup or screen , as indicated by user 2676075, so that your jobs continue to work after closing a terminal session, for example
nohup command1 > file1 2>&1 & nohup command2 > file2 2>&1 & nohup command3 > file3 2>&1 &
source share