Reputation: 6671
I'm interested in finding out how I'm able to do the following, but automatically.
Right now I have a bash script that looks something like this:
#!/bin/sh
sass --watch htdocs/css/scss:htdocs/css --debug-info
Now, because I want to be able to run other command-line tasks at the same time as this script is running, I could just run it inside a new window, but I prefer to have it run as a background process, which I achieve by:
bg
Which lets me continue to use the command-line, while also seeing the output from the sass
command.
I'm also able to use jobs
to see what's running, and finally, fg
to bring the background script to the forefront, and use [ctrl] + [c] to cancel out of it.
All of which is fine, but it's a bit long-winded - is there any way that I can edit the bash script so it will automatically run in the background, similar to what I've described above?
Thank you
Upvotes: 0
Views: 1773
Reputation: 124
An alternative to this , which I found useful is to write a function
Foo(){
Do stuff
}
and call the function and send it to the background
Foo &
All within the script, so you don't have to do
script.sh &
Instead, just invoking the script will send it to the background.
Upvotes: 0