I would like to know how I can run two ongoing processes at the same time in Linux/bash. basically, I have a Node web server, and a MJPG-Streamer server. I want to run both these processes at once, but they are ongoing processes. I heard about running them as background processes, but I want them to be the same priority as a foreground process.
migrated from stackoverflow.com Feb 3 '14 at 22:22
This question came from our site for professional and enthusiast programmers.
When you say priority, you probably mean the nice-level of the process. To quote Wikipedia:
Running a process in the background does not inflict on it's nice-level. It's entirely the same as when you're running it in the foreground.
So you can easily run your application/process in the background by invoking it with a trailing '&'-sign:
You can also send a foreground-process to the background, by pressing ctrl+z (pauses the execution) followed by bg+enter.
You can list running background-tasks with the command jobs.
To get it back to the foreground you must find out its job-ID with the jobs-command, and run fg [job-ID] (for example: fg 1)
Background tasks will send all their output to your shell. If you don't want to see their output, you'll need to redirect it to /dev/null:
...which will redirect normal output into the void. Errors will still be visible.
If you want to run the two processes from the same console or xterm in the foreground, you could consider running them inside screen or tmux sessions, which are terminal multiplexers. The processes won't run under the same shell process then, but under separate shell processes.
E.g. using screen:
See screen manual for more info.