I am trying to merge multiple linux commands in one line to perform deployment operation. For example
nohup php 1.php
nohup php 2.php
nohup php 3.php
nohup php 4.php
I want perform all of them in parallel, it is possible in a .sh file?
In linux you can use &&
to execute commands sequentially, and a command will only execute if the previous one succeeded.
nohup php 1.php && nohup php 2.php && nohup php 3.php
Edit: in case you do not want the error-checking provided by the &&
operator, use the semicolon (;)
to chain the commands, like this:
nohup php 1.php ; nohup php 2.php ; nohup php 3.php
you can also do-it like that :
edit : to answer your question, the process are parallel. you can verify this by writing the
ps
command. eg : with thesleep
command :output :
edit 2 : Ok then try with
parallel
command. (you probably have to install it)Create a file
cmd.txt
:Then execute this command (haven't tried yet, but it should work). you can change the
--max-procs
numbers if you have more/less than 4 core :hope it works...