how to deal with two processes that run in parallel?
There is a lot of possible answer, using or not screen
, tmux
or tools, or running as background tasks, using separated log files...
Running two process separatedly
You could use named fifo:
mkfifo $HOME/mysqlFifo
Then run in two separated terminal console:
mysqldump --host host1 --databases db1 db2 db3 >$HOME/mysqlFifo
and in second window:
mysql <$HOME/mysqlFifo
Then let it run...
I want to close PuTTY and still be able to get back to them later?
screen
too
Some preparation:
cat >$HOME/mysqlScreenRc <<eof
screen -t dump mysqldump --host host1 --databases db1 db2 db3 >$HOME/mysqlFifo
screen -t mysql mysql <$HOME/mysqlFifo
eof
mkfifo $HOME/mysqlFifo
then
screen -S mysql -c $HOME/mysqlScreenRc
or
screen -dmS mysql -c $HOME/mysqlScreenRc
to let it run in background...
Then to connect and watch:
screen -r mysql
For ensuring screen stay open afte commands terminated, you could use read
command:
cat >$HOME/mysqlScreenRc <<eof
screen -t dump sh -c 'mysqldump --host host1 --databases db1 db2 db3 >$HOME/mysqlFifo;read foo'
screen -t mysql sh -c 'mysql <$HOME/mysqlFifo;read foo'
eof
But you could just run in background with separated logs:
nohup mysqldump --host host1 --databases db1 db2 db3 2>/somepath/mysqldump.err |
mysql >/somepath/mysql.log 2>/somepath/mysql.err &
So you could close this console, then watch about files in /somepath
...