Run two commands in same time

It should be very useful to be able to run two command in the same time.
For example if you need to compare different counters on two different commands in a different time
You can do this quicky without writing a complex script like this:

pateretou@crapules:~/work/rdh$ cat 
echo -e "primaire\n" > /tmp/output1.log && ethtool -S eth0 | egrep "rx_error|tx_error" >> /tmp/output1.log &
echo -e "primaire\n" > /tmp/output2.log && ethtool -S eth1 | egrep "rx_error|tx_error"
>> /tmp/output2.log &
cat /tmp/output{1,2}.log > output.log
rm /tmp/output{1,2}.log
pateretou@crapules:~/work/rdh$ cat output.log 
 rx_errors: 0
 tx_errors: 0
 rx_errors: 0
 tx_errors: 0

You are now able to run again your script later and both command will be run in the same time without desynchronization

This entry was posted in Linux, sh and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *