Cron не резервирует мой Mongodb

У меня проблема с моим Cron на Ubuntu 16.04. Я проверил, что служба cron запущена и работает, но скрипты, которые создают резервные копии Mongo DB, вероятно, не выполняются.

Это мое / etc / crontab содержимое файла:

# /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 ) #

и здесь это мой файл db_backup.sh:

#!/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

Когда я запускаю в терминале: sh /etc/cron.hourly/db_backup.sh

Создает резервную копию Mongo DB с датой даты name in / db_backups / somedate

Почему мой скрипт не работает каждые 10 минут и 1 час? Как видите, я помещаю скрипт в папку cron.hourly, но ничего не происходит ни 10 минут, ни 1 час.

0
задан 31 May 2017 в 15:43

6 ответов

Я обновил некоторые из моих файлов здесь и успешно создал cron для обновления моего Mongo DB ежедневно. Подробности здесь: https://stackoverflow.com/questions/44296616/cron-job-doesnt-work-ubuntu-16-04 / 44296690? noredirect = 1 # comment75599631_44296690

0
ответ дан 22 May 2018 в 22:02

Я обновил некоторые из моих файлов здесь и успешно создал cron для обновления моего Mongo DB ежедневно. Подробности здесь: https://stackoverflow.com/questions/44296616/cron-job-doesnt-work-ubuntu-16-04 / 44296690? noredirect = 1 # comment75599631_44296690

0
ответ дан 18 July 2018 в 12:25

Я обновил некоторые из моих файлов здесь и успешно создал cron для обновления моего Mongo DB ежедневно. Подробности здесь: https://stackoverflow.com/questions/44296616/cron-job-doesnt-work-ubuntu-16-04 / 44296690? noredirect = 1 # comment75599631_44296690

0
ответ дан 24 July 2018 в 19:57

Из раздела DEBIAN SPECIFIC раздела man cron:

As described above, the files under these directories have to be pass some sanity checks including the following: be executable, be owned by root, not be writable by group or other and, if symlinks, point to files owned by root. Additionally, the file names must conform to the filename requirements of run-parts: they must be entirely made up of letters, digits and can only contain the special signs underscores ('_') and hyphens ('-'). Any file that does not conform to these requirements will not be executed by run-parts. For example, any file containing dots will be ignored. This is done to prevent cron from running any of the files that are left by the Debian package management system when handling files in /etc/cron.d/ as configuration files (i.e. files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
2
ответ дан 22 May 2018 в 22:02
  • 1
    Я проверил имена файлов в порядке, удалил даже подчеркивание из имени файла и каталога и ничего. Возможно ли, что этот файл «dbbackup.sh» должен быть без точки .sh? И расширения? – Nezir 31 May 2017 в 17:24
  • 2
    @zire подчеркивания допустимы , периоды («точки») не являются – steeldriver 31 May 2017 в 17:30
  • 3
    Я попытался удалить файл .sh, но ничего не повторится @steeldriver – Nezir 31 May 2017 в 17:44

Из раздела DEBIAN SPECIFIC раздела man cron:

As described above, the files under these directories have to be pass some sanity checks including the following: be executable, be owned by root, not be writable by group or other and, if symlinks, point to files owned by root. Additionally, the file names must conform to the filename requirements of run-parts: they must be entirely made up of letters, digits and can only contain the special signs underscores ('_') and hyphens ('-'). Any file that does not conform to these requirements will not be executed by run-parts. For example, any file containing dots will be ignored. This is done to prevent cron from running any of the files that are left by the Debian package management system when handling files in /etc/cron.d/ as configuration files (i.e. files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
2
ответ дан 18 July 2018 в 12:25

Из раздела DEBIAN SPECIFIC раздела man cron:

As described above, the files under these directories have to be pass some sanity checks including the following: be executable, be owned by root, not be writable by group or other and, if symlinks, point to files owned by root. Additionally, the file names must conform to the filename requirements of run-parts: they must be entirely made up of letters, digits and can only contain the special signs underscores ('_') and hyphens ('-'). Any file that does not conform to these requirements will not be executed by run-parts. For example, any file containing dots will be ignored. This is done to prevent cron from running any of the files that are left by the Debian package management system when handling files in /etc/cron.d/ as configuration files (i.e. files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
2
ответ дан 24 July 2018 в 19:57
  • 1
    Я проверил имена файлов в порядке, удалил даже подчеркивание из имени файла и каталога и ничего. Возможно ли, что этот файл «dbbackup.sh» должен быть без точки .sh? И расширения? – Nezir 31 May 2017 в 17:24
  • 2
    @zire подчеркивания допустимы , периоды («точки») не являются – steeldriver 31 May 2017 в 17:30
  • 3
    Я попытался удалить файл .sh, но ничего не повторится @steeldriver – Nezir 31 May 2017 в 17:44

Другие вопросы по тегам:

Похожие вопросы: