Hi everyone,
While configuration crontab for auto start mongod, I have a problem that it cannot work as schedule, but when I run it by myself, it work. Are there any mistake?
The command I set as below:
– This is cronjob
[root@omnidrp-opsmanager01 ~]# crontab -l
*/1 * * * * sh /root/scripts/mms_check_status.sh
– The script
[root@omnidrp-opsmanager01 ~]# cat scripts/mms_check_status.sh
#!/bin/bash
#check port mms 27019 is running or not
#if not, run command mongod to start
if ! netstat -nltp | grep 27019; then
mongod --port 27019 --dbpath “/mongo/data/appdb” --logpath “/mongo/data/appdb/mongodb.log” --wiredTigerCacheSizeGB 8 --fork
fi
Thank all!