I would like to create an alias that:
- changes directories
- starts redis
- starts a node application
I was able to do this by creating an alias like the one below:
alias startSP='cd mydirectory; redis-server;node myApp.js'
The issue is that the node myApp.js pieces doesn’t run until I kill redis. Is there some way that I can start two processes without waiting for the first to finish?
Should I be trying to open a second tab to do this?
I don’t have a way to test this, but adding the ‘&’ to run cmd in background should work, i.e.
You will probably want to add a 2nd &, ie
As this will return the prompt to you and you can keep working at your commandline.
edit
There are many ways to kill processes, search here on S.O. If you lucky, you’ll be able to do
There are a lot of ways to get this wrong, so you’ll do better to examine your particular case.
If I was going to do this all the time, I would turn
startPSinto a function that captured the PIDs returned from using the ‘&’, saved those pids to the environment, and then had a seperate function that could confirm those PIDs existed, AND that they had a high probability of being the correct program, THEN issue the kill.Note also, that
kill -15is the preferred way to kill a program, giving it the chance to close files, etc.IHTH.