{ "created": "2015-12-20T19:56:48Z", "hierarchy": [ { "name": "ROOT", "type": "folder", "uri": "/ROOT" }, { "name": "Foreground and Background Processes Management", "type": "article", "uri": "Foreground_and_Background_Processes_Management" } ], "html": "\n\n \n \n \n \n \n \n \n \n \n \n \n Foreground and Background Processes Management – Nikhil's Personal Wiki\n \n \n \n \n \n
\n
\n \n
\n
\n \n \n\n

Foreground and Background Processes Management\n \n

\n

To illustrate, here’s a directory listing:

\n
user@example:~/scripts/trunk/backup_scripts# ls -l  \ntotal 76  \n-rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh  \n-rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh  \n-rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh  \n-rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh  \n-rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh  \n-rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh  \n-rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh  \n-rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh  \n-rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh  \n-rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh\n
\n

Let’s say I started editing a file (e.g. vim backup.sh. I now hit
\nCtrl+z to ‘push’ the process into the background. This is what I see:

\n
[1]+  Stopped                 vim backup.sh  \nuser@support:~/scripts/trunk/backup_scripts#\n
\n

Now I edit another file (or start another process) and hit Ctrl+z
\nagain:

\n
[2]+  Stopped                 vim backup.subversion.sh  \nuser@support:~/scripts/trunk/backup_scripts#\n
\n

And so on. To list all my background jobs, I can either issue ps
\nor (better) jobs:

\n
user@support:~/scripts/trunk/backup_scripts# ps  \n  PID TTY          TIME CMD  \n 3561 pts/0    00:00:00 bash  \n 3697 pts/0    00:00:00 vim  \n 3728 pts/0    00:00:00 vim  \n 3773 pts/0    00:00:00 vim  \n 3790 pts/0    00:00:00 top  \n 3797 pts/0    00:00:00 ps\n\nuser@support:~/scripts/trunk/backup_scripts# jobs  \n[1]   Stopped                 vim backup.sh  \n[2]+  Stopped                 vim backup.subversion.sh  \n[3]   Stopped                 vim backup.network.sh  \n[4]-  Stopped                 top\n
\n

The “+” and “-” signs indicate the first and second most recent jobs
\nrespectively. Typing fg will bring the job tagged with a “+” into the
\nforeground. From the output above, let’s say you wanted to bring top
\ninto the foreground instead:

\n
user@support:~/scripts/trunk/backup_scripts# fg 4\n
\n

To keep top running in the background for example (“amping off”), you
\nwould just type bg 4

\n

References

\n\n\n\n
\n \n
\n \n \n \n \n \n\n", "id": "c0ce56b7-6728-5ec1-9fbe-0198844cd634", "modified": "2024-04-15T23:13:03Z", "revisions": [ { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2024-04-15T23:13:03Z", "id": "1f343266dce411121f0cff3ca7e3e0632be6ce97", "shortId": "1f343266", "subject": "Some more notes\n", "content": "To illustrate, here's a directory listing:\n\n user@example:~/scripts/trunk/backup_scripts# ls -l \n total 76 \n -rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh \n -rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh \n -rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh \n -rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh \n -rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh \n -rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh \n -rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh \n -rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh \n -rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh \n -rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh\n\nLet's say I started editing a file (e.g. `vim backup.sh`. I now hit\n`Ctrl+z` to 'push' the process into the background. This is what I see:\n\n [1]+  Stopped                 vim backup.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nNow I edit another file (or start another process) and hit `Ctrl+z`\nagain:\n\n [2]+  Stopped                 vim backup.subversion.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nAnd so on. To list all my background jobs, I can either issue **`ps`**\nor (better) **`jobs`**:\n\n user@support:~/scripts/trunk/backup_scripts# ps \n   PID TTY          TIME CMD \n  3561 pts/0    00:00:00 bash \n  3697 pts/0    00:00:00 vim \n  3728 pts/0    00:00:00 vim \n  3773 pts/0    00:00:00 vim \n  3790 pts/0    00:00:00 top \n  3797 pts/0    00:00:00 ps\n\n user@support:~/scripts/trunk/backup_scripts# jobs \n [1]   Stopped                 vim backup.sh \n [2]+  Stopped                 vim backup.subversion.sh \n [3]   Stopped                 vim backup.network.sh \n [4]-  Stopped                 top\n\nThe \"+\" and \"-\" signs indicate the first and second most recent jobs\nrespectively. Typing `fg` will bring the job tagged with a \"+\" into the\nforeground. From the output above, let's say you wanted to bring `top`\ninto the foreground instead:\n\n user@support:~/scripts/trunk/backup_scripts# fg 4\n\nTo keep `top` running in the background for example (\"amping off\"), you\nwould just type `bg 4`\n\nReferences\n----------\n\n- [The Shell - The Linux Cookbook](http://www.dsl.org/cookbook/cookbook_5.html)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-27T07:27:56Z", "id": "5a5b1a32f41081d062ab86f8869a961bcad79668", "shortId": "5a5b1a32", "subject": "Fix Markdown conversion\n\nSaw half a season of The Office\n", "content": "To illustrate, here's a directory listing:\n\n user@example:~/scripts/trunk/backup_scripts# ls -l \n total 76 \n -rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh \n -rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh \n -rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh \n -rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh \n -rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh \n -rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh \n -rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh \n -rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh \n -rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh \n -rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh\n\nLet's say I started editing a file (e.g. `vim backup.sh`. I now hit\n`Ctrl+z` to 'push' the process into the background. This is what I see:\n\n [1]+  Stopped                 vim backup.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nNow I edit another file (or start another process) and hit `Ctrl+z`\nagain:\n\n [2]+  Stopped                 vim backup.subversion.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nAnd so on. To list all my background jobs, I can either issue **`ps`**\nor (better) **`jobs`**:\n\n user@support:~/scripts/trunk/backup_scripts# ps \n   PID TTY          TIME CMD \n  3561 pts/0    00:00:00 bash \n  3697 pts/0    00:00:00 vim \n  3728 pts/0    00:00:00 vim \n  3773 pts/0    00:00:00 vim \n  3790 pts/0    00:00:00 top \n  3797 pts/0    00:00:00 ps\n\n user@support:~/scripts/trunk/backup_scripts# jobs \n [1]   Stopped                 vim backup.sh \n [2]+  Stopped                 vim backup.subversion.sh \n [3]   Stopped                 vim backup.network.sh \n [4]-  Stopped                 top\n\nThe \"+\" and \"-\" signs indicate the first and second most recent jobs\nrespectively. Typing `fg` will bring the job tagged with a \"+\" into the\nforeground. From the output above, let's say you wanted to bring `top`\ninto the foreground instead:\n\n user@support:~/scripts/trunk/backup_scripts# fg 4\n\nTo keep `top` running in the background for example (\"amping off\"), you\nwould just type `bg 4`\n\nReferences\n----------\n\n- [The Shell - The Linux Cookbook](http://www.dsl.org/cookbook/cookbook_5.html)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-21T02:30:47Z", "id": "3f2c54b1d767218fcb4855fbac306b015afaf551", "shortId": "3f2c54b1", "subject": "Incremental\n", "content": "To illustrate, here's a directory listing:\n\n` user@example:~/scripts/trunk/backup_scripts# ls -l` \n` total 76` \n` -rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh` \n` -rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh` \n` -rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh` \n` -rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh` \n` -rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh` \n` -rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh` \n` -rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh` \n` -rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh` \n` -rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh` \n` -rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh`\n\nLet's say I started editing a file (e.g. `vim backup.sh`. I now hit\n`Ctrl+z` to 'push' the process into the background. This is what I see:\n\n` [1]+  Stopped                 vim backup.sh` \n` user@support:~/scripts/trunk/backup_scripts#`\n\nNow I edit another file (or start another process) and hit `Ctrl+z`\nagain:\n\n` [2]+  Stopped                 vim backup.subversion.sh` \n` user@support:~/scripts/trunk/backup_scripts#`\n\nAnd so on. To list all my background jobs, I can either issue **`ps`**\nor (better) **`jobs`**:\n\n` user@support:~/scripts/trunk/backup_scripts# ps` \n`   PID TTY          TIME CMD` \n`  3561 pts/0    00:00:00 bash` \n`  3697 pts/0    00:00:00 vim` \n`  3728 pts/0    00:00:00 vim` \n`  3773 pts/0    00:00:00 vim` \n`  3790 pts/0    00:00:00 top` \n`  3797 pts/0    00:00:00 ps`\n\n` user@support:~/scripts/trunk/backup_scripts# jobs` \n` [1]   Stopped                 vim backup.sh` \n` [2]+  Stopped                 vim backup.subversion.sh` \n` [3]   Stopped                 vim backup.network.sh` \n` [4]-  Stopped                 top`\n\nThe **+** and **-** signs indicate the first and second most recent jobs\nrespectively. Typing `fg` will bring the job tagged with a \"+\" into the\nforeground. From the output above, let's say you wanted to bring `top`\ninto the foreground instead:\n\n` user@support:~/scripts/trunk/backup_scripts# fg `**`4`**\n\nTo keep `top` running in the background for example (\"amping off\"), you\nwould just type `bg 4`\n\nReferences\n----------\n\n- [The Shell - The Linux\n Cookbook](http://www.dsl.org/cookbook/cookbook_5.html)\n\n\n\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-20T19:56:48Z", "id": "2a171a06453d6bdcc20289a4d246ce69442828e3", "shortId": "2a171a06", "subject": "Foreground and Background Processes Management : First Draft", "content": "To illustrate, here's a directory listing:\n\n` user@example:~/scripts/trunk/backup_scripts# ls -l` \n` total 76` \n` -rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh` \n` -rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh` \n` -rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh` \n` -rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh` \n` -rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh` \n` -rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh` \n` -rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh` \n` -rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh` \n` -rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh` \n` -rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh`\n\nLet's say I started editing a file (e.g. `vim backup.sh`. I now hit\n`Ctrl+z` to 'push' the process into the background. This is what I see:\n\n` [1]+  Stopped                 vim backup.sh` \n` user@support:~/scripts/trunk/backup_scripts#`\n\nNow I edit another file (or start another process) and hit `Ctrl+z`\nagain:\n\n` [2]+  Stopped                 vim backup.subversion.sh` \n` user@support:~/scripts/trunk/backup_scripts#`\n\nAnd so on. To list all my background jobs, I can either issue **`ps`**\nor (better) **`jobs`**:\n\n` user@support:~/scripts/trunk/backup_scripts# ps` \n`   PID TTY          TIME CMD` \n`  3561 pts/0    00:00:00 bash` \n`  3697 pts/0    00:00:00 vim` \n`  3728 pts/0    00:00:00 vim` \n`  3773 pts/0    00:00:00 vim` \n`  3790 pts/0    00:00:00 top` \n`  3797 pts/0    00:00:00 ps`\n\n` user@support:~/scripts/trunk/backup_scripts# jobs` \n` [1]   Stopped                 vim backup.sh` \n` [2]+  Stopped                 vim backup.subversion.sh` \n` [3]   Stopped                 vim backup.network.sh` \n` [4]-  Stopped                 top`\n\nThe **+** and **-** signs indicate the first and second most recent jobs\nrespectively. Typing `fg` will bring the job tagged with a \"+\" into the\nforeground. From the output above, let's say you wanted to bring `top`\ninto the foreground instead:\n\n` user@support:~/scripts/trunk/backup_scripts# fg `**`4`**\n\nTo keep `top` running in the background for example (\"amping off\"), you\nwould just type `bg 4`\n\nReferences\n----------\n\n- [The Shell - The Linux\n Cookbook](http://www.dsl.org/cookbook/cookbook_5.html)\n\n[Category:Nikhil's Notes](Category:Nikhil's_Notes \"wikilink\")\n[Category:From a past sysadmin\nlife](Category:From_a_past_sysadmin_life \"wikilink\")\n" } ], "sizeInBytes": 2647, "source": "To illustrate, here's a directory listing:\n\n user@example:~/scripts/trunk/backup_scripts# ls -l \n total 76 \n -rwxr-xr-x 1 user user   894 2011-06-27 10:00 backup.hwaddr.sh \n -rwxr-xr-x 1 user user 12175 2011-05-02 22:54 backup.local.sh \n -rwxr-xr-x 1 user user  6194 2011-04-12 16:53 backup.mysql.sh \n -rwxr-xr-x 1 user user 14638 2011-04-28 11:29 backup.network.sh \n -rwxr-xr-x 1 user user  3201 2011-05-02 09:06 backup.opendirectory.sh \n -rwxr-xr-x 1 user user  7871 2011-04-28 11:32 backup.rotate.sh \n -rwxr-xr-x 1 user user  3743 2011-04-12 16:53 backup.rpms.sh \n -rwx------ 1 user user  5037 2011-06-28 15:03 backup.sh \n -rwxr-xr-x 1 user user  4184 2011-06-27 10:01 backup.staging.sh \n -rwxr-xr-x 1 user user  3128 2011-06-27 10:58 backup.subversion.sh\n\nLet's say I started editing a file (e.g. `vim backup.sh`. I now hit\n`Ctrl+z` to 'push' the process into the background. This is what I see:\n\n [1]+  Stopped                 vim backup.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nNow I edit another file (or start another process) and hit `Ctrl+z`\nagain:\n\n [2]+  Stopped                 vim backup.subversion.sh \n user@support:~/scripts/trunk/backup_scripts#\n\nAnd so on. To list all my background jobs, I can either issue **`ps`**\nor (better) **`jobs`**:\n\n user@support:~/scripts/trunk/backup_scripts# ps \n   PID TTY          TIME CMD \n  3561 pts/0    00:00:00 bash \n  3697 pts/0    00:00:00 vim \n  3728 pts/0    00:00:00 vim \n  3773 pts/0    00:00:00 vim \n  3790 pts/0    00:00:00 top \n  3797 pts/0    00:00:00 ps\n\n user@support:~/scripts/trunk/backup_scripts# jobs \n [1]   Stopped                 vim backup.sh \n [2]+  Stopped                 vim backup.subversion.sh \n [3]   Stopped                 vim backup.network.sh \n [4]-  Stopped                 top\n\nThe \"+\" and \"-\" signs indicate the first and second most recent jobs\nrespectively. Typing `fg` will bring the job tagged with a \"+\" into the\nforeground. From the output above, let's say you wanted to bring `top`\ninto the foreground instead:\n\n user@support:~/scripts/trunk/backup_scripts# fg 4\n\nTo keep `top` running in the background for example (\"amping off\"), you\nwould just type `bg 4`\n\nReferences\n----------\n\n- [The Shell - The Linux Cookbook](http://www.dsl.org/cookbook/cookbook_5.html)\n", "title": "Foreground and Background Processes Management", "untracked": false, "uri": "/Foreground_and_Background_Processes_Management", "relativePath": "Foreground and Background Processes Management.md" }