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?
you can also do-it like that :
nohup sh -c 'php 1.php; php 2.php; php 3.php' &
edit :
to answer your question, the process are parallel. you can verify this by writing the ps
command.
eg : with the sleep
command :
nohup sh -c 'sleep 30 && sleep 30' &
output :
....
6920 7340 7340 6868 pty2 17763 16:33:27 /usr/bin/sleep
6404 4792 4792 7004 pty2 17763 16:33:26 /usr/bin/sleep
....
edit 2 :
Ok then try with parallel
command. (you probably have to install it)
Create a file cmd.txt
:
1.php
2.php
3.php
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 :
cat cmd.txt | parallel --max-procs=4 --group 'php {}'
hope it works...