Mongodb ubuntu - config server and shard together
An easy way to achieve that is to use cron's @reboot feature:

&gt; crontab -e -u mongodb
@reboot /usr/bin/mongod --configsvr --dbpath /data/configdb/ --port 21001 --logpath /var/log/mongodb/configsvr.log --fork
@reboot /usr/bin/mongod --shardsvr --dbpath /data/db/ --port 31001 --logpath /var/log/mongodb/mongod.log --fork


However, you have to make sure that /etc/security/limits.conf holds the correct values.