How to disable creation of ~/.mongodb/mongosh
directory and files in it ? Each run of mongosh utility it creates a log file under ~/.mongodb/mongosh
. I am tired of them. How can I disable creation of any cache/log/etc files from mongosh ?
I tried to remove .mongodb
directory and create file with that name (touch ~/.mongodb
), but now mongosh outputs
Warning: Could not access file: ENOTDIR: not a directory, mkdir ‘/USER/.mongodb/mongosh’
and outputs this to stdout (!!!) not to stderr.
I need to detect if MongoDB server is running in replicaSet mode on a specific node in order to make proper connection during daily backup (whether or not to add ?replicaSet=$replicaset_name
to the connection URL). So I run
replicaset_name=`mongosh --quiet --eval ‘try { rs.status().set } catch (e) {}’ 2> /dev/null`
in a script and I get either infinite log files creation or an error to stdout
Warning: Could not access file: ENOTDIR: not a directory, mkdir ‘/USER/.mongodb/mongosh’
This is terrible, old mongo CLI (4.x) didn’t have such problems. How to avoid this with mongosh ?