Answer the question
In order to leave comments, you need to log in
What is the correct way to make a cron job in ubuntu 18.04?
There is such a file
#!/bin/bash
#сделать полное архивирование, если со дня последнего полного архивирования прошел 14 дней;
duplicity --no-encryption --verbosity info --volsize 1024 --exclude /media --exclude /dev --exclude /proc --exclude /tmp --exclude /run --exclude /mnt --exclude /sys --exclude=/mnt --exclude=/proc --exclude=/tmp --exclude=/home --full-if-older-than 14D / file:///media/gray/4tb/backup/
# дамп mysql
mysqldump -u nextcloud2 [email protected] nextcloud2 | gzip > `date +/home/gray/bnvp0_sql/dump.sql.%Y.%m.%d_%H.%M.gz`
#удалить резервные копии старше, чем Х месяцев.
duplicity remove-older-than 1M --force file:///media/gray/4tb/backup/
#восстановить файлы
#duplicity restore file:///media/gray/4tb/backup/ /media/gray/4tb/test/ --no-encryption
#восстановление конкретного файла или папки (Во время восстановления каталога, папки создавать вручную не надо. Если восстанавливаете файл, то полный путь к конечной директории должен существовать.)
#duplicity --no-encryption --file-to-restore var/log file:///mnt/yadisk /restore/var/log
#duplicity --no-encryption --file-to-restore var/log/messages file:///mnt/yadisk /restore/var/log/messages
#посмотреть статус архивов
#duplicity collection-status --no-encryption file:///media/gray/4tb/backup/
#подробнее https://serveradmin.ru/backup-linux-servera-s-pomoshhyu-duplicity/
sudo nano / etc / crontab
0 * * * * root /home/backup.sh
Answer the question
In order to leave comments, you need to log in
In the console (terminal) of Ubuntu, execute the command
This will allow you to edit jobs for cron. After executing the command, you will see something like this in the terminal
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
###
ВОТ ТУТ ПИШИТЕ СВОЁ РАСПИСАНИЕ ДЛЯ CRON
###
* * * * * /home/$user/bash.sh
crontab -l
crontab -u UserName -e
you specify which user cron will run as. /var/spool/cron/crontabs
. A file named after the system user name will be created in this directory. Here it is just edited through crontab -e
. /etc/cron.d
. In this case, you must specify the username under which the task will be launched. /etc/cron.daily
, /etc/cron.hourly
, /etc/cron.monthly
,/etc/cron.weekly
. In these directories, you can place files with tasks that will run daily, hourly, monthly and weekly, respectively.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question