I have a Shell command that I'd like to run in the background and I've read that this can be done by suffixing an &
to the command which causes it to run as a background process but I need some more functionality and was wondering how to go about it:
service apache2 start
.How can I go about this? Is there a tool that allows me to run a command as a service?
I'm a little lost with this.
Thanks
If you want to run additional commands while a previous command runs, you can run a command in the background. If you know you want to run a command in the background, type an ampersand (&) after the command as shown in the following example. The number that follows is the process id.
The bg command is used to resume a background process. It can be used with or without a job number. If you use it without a job number the default job is brought to the foreground. The process still runs in the background.
A background process is a computer process that runs behind the scenes (i.e., in the background) and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.
UNIX systems can handle as many processes as you need simultaneously (just open new shell windows if you're in a GUI), so running a process in the background is only necessary if you need to carry on using the current shell window for other things once you've run an application or process that keeps running.
To run a command called command in background mode, you'd use:
command &
This is a special character that returns you to the command prompt once the process is started. There are other special characters that do other things, more info is available here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With