Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Alternatively, you can put "&" after the command before closing the shell, which daemonizes the child process. If the child process is already running, you can temporarily suspend it by hitting Ctrl-Z, then typing in "bg" (which "continues" the process daemonized). To bring the process back to the foreground, run "fg".
Code:
$ sleep 100 # this is the process we'll daemonize
^Z # Ctrl-Z is immediate, Ctrl-Y suspends the process when it tries to read input
[1]+ Stopped sleep 100
$ bg # short for "background"...only works on suspended processes
[1]+ sleep 100 & <~~~ same as if you'd run "sleep 100 &" from the start
$ time sleep 5 # a different "sleep" process
real 0m5.003s
user 0m0.004s
sys 0m0.000s
$ fg # bring the "old" sleep process that we daemonized back to the foreground
sleep 100
^C
$ sleep 200 & # daemonize the process from the start
[1] 2117
$ ps aux | grep sleep # look at the daemonized process
user 2117 0.0 0.0 3232 616 pts/1 S 22:33 0:00 sleep 200
$ fg # bring the daemonized process back to the foreground
sleep 200
^C
$
Posted 11-08-2011 at 10:35 PM byrocket357 Updated 11-08-2011 at 10:42 PM byrocket357
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.