mkdir backup touch monitoring.sh
#!/bin/bash currentDate=`date +"%Y%m%d%H%M"` dirName="monitoring_$currentDate" filePath=/home/mahmood/backup/$dirName mkdir $filePath mongodump --db monitoring --out $filePath
sudo chmod +x monitoring.sh
sudo crontab -e
30 4 * * * /home/mahmood/backup/monitoring.sh
References
https://stackoverflow.com/questions/35574603/run-cron-job-everyday-at-specific-time
https://tecadmin.net/get-current-date-and-time-in-bash/
https://askubuntu.com/questions/350861/how-to-set-a-cron-job-to-run-a-shell-script
https://coderwall.com/p/hdmmnq/easy-automatic-nightly-backups-for-mongodb