Running two commands in background

Hi I want to run two commands in background, i am using below way, but it is not working, i m calling these two commands from one script to another server where below commands are running, in my script ssh is working fine, but command is not going in background, please advise what should i do.


command1 && command2 

OK, how do you usually run commands in background?

If available, maybe use the nohup command. It has the added benefit of surviving a logout from a system.

nohup command1 > command1.out &

If its the code you submitted above that is executed, you would have to explain to me how you have the 2 commands running ( not even mentionning background...)... Truely it puzzles me

&& is logical AND. Your example runs command1 in the foreground, and then once (if) it completes successfully it runs command2 in the foreground.

To run a command in the background you'd use & , as in in2nix4life's example.

Hello All,

Its requirement of some job which we need to enable and wants to run these two commands in background, manually if i run from console it takes 20 minutes, so i want to run in background these two command and then want to continue for second task after leaving them running in background.

---------- Post updated at 11:06 AM ---------- Previous update was at 10:59 AM ----------

But how i can run two command with nohup in background, i am totally lost on this.

command1 &
command2 &
nohup bash -c 'command1 && command2' > cmds.out &

This is not possible actually i am passing this script through application which not allow me to do on second line.

I have tried this but no luck.

command1 &; command2
bash: syntax error near unexpected token `;'

Try command1 & command2 &

Is there any way i just run the both commands in such a way that it will go in background not gives me a single output. Just keep running in background, I don't want whether it finish or not, just wants to put in background. if i follow above way, it is waiting for ouput.