简体   繁体   中英

can I connect bash to an existing mongod process?

I run two mongo databases on my dev machine. The first runs on the standard port and (apparently) runs at startup. The second I start up as part of my "kickoff the dev env" script. How can I get the output from the first database in bash? I'm talking about the output that looks like:

Wed Oct 30 16:28:27.035 [initandlisten] recover : no journal files present, no recovery needed
Wed Oct 30 16:28:27.215 [initandlisten] waiting for connections on port XX987
Wed Oct 30 16:28:27.216 [websvr] admin web console waiting for connections on port XX987
Wed Oct 30 16:28:34.054 [initandlisten] connection accepted from 127.0.0.1:53736 #1 (1 connection now open)
Wed Oct 30 16:28:34.060 [conn1] end connection 127.0.0.1:53736 (0 connections now open)
Wed Oct 30 16:28:34.061 [initandlisten] connection accepted from 127.0.0.1:53737 #2 (1 connection now open)

Is this called a listening socket? How can I connect to this output from bash?

It looks like you are showing the output of the mongodb log file. In order to separate the log messages of the different mongo processes you'll need to configure separate log file locations for both mongo processes. Then you can just:

tail -f /path/to/mongo_dev/logfile

You can change the log file location of a mongodb process by setting

logpath=/path/to/anyhwere.log

in it's config file. Then restart the mongodb process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM