In our previous tutorial, you have learned about how to start or run command in background. Now this tutorial will help you to how to move running command in background. This is helpful, if you have started a command on terminal and that command is taking to much time. Now you want to move that in background, so that you can continue with other tasks.
Move Running Command in Background
For example you are taking a backup of large number of files, You have started command on terminal, But after mid of this task you think that this is taking longer time and you have some other pending tasks like below:
[email protected]:~$ tar czf log-backup.tar.gz /var/log
CTRL + Z + Stopped tar czf log-backup.tar.gz /var/log
[email protected]:~$ bg + tar czf log-backup.tar.gz /var/log &
List Running Commands in Background
To list all jobs running in background use jobs command. It will show all running commands with their job id.
[email protected]:~$ jobs + Running tar czf log-backup.tar.gz /var/log &
Move Background Commands to Foreground (Terminal)
Now, If you need to any background jobs to move to foreground. Use
[email protected]:~$ fg 1