I have a problem with my Cron on Ubuntu 16.04. I checked that cron service is up and running but scripts that create Mongo DB backups probably is not run.
This is my /etc/crontab file content:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
*/10 * * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.hourly )
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
and here is my db_backup.sh file content:
#!/bin/sh
DIR=`date +%m%d%y`
DEST=/db_backups/$DIR
mkdir $DEST
mongodump -h localhost:27017 -d dbname -u xxxx -p xxx -o $DEST
When I run in terminal: sh /etc/cron.hourly/db_backup.sh
Its create Mongo DB backup with dir date name in /db_backups/somedate
Why my script not running every 10 minutes and 1 hour?
As you can see I put script in cron.hourly folder but nothings happen neither 10 minutes or 1 hour.
From the
DEBIAN SPECIFIC
section ofman cron
:I did update some of my files here and successfully created cron for updating my Mongo DB daily more details here: https://stackoverflow.com/questions/44296616/cron-job-doesnt-work-ubuntu-16-04/44296690?noredirect=1#comment75599631_44296690