我设置了一个 cron 作业来启动 Restic 以备份数据。cron 作业似乎正在运行,但显然没有执行任何任务。
在 etc/crontab 中有下面的 cron 作业
vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
59 * * * * root . ~/.restic.env ; /usr/local/bin/restic backup --files-from=/root/restic.files --tag automated 2>> ~/restic.err >> ~/restic.log
在修改 /etc/crontab 中的文件后,我做了 systemctl restart crond
文件 restic.err 和 restic.log 是空的
自从我初始化存储库以来,命令 restic snapshots 没有显示任何新条目。
tail - f /var/log/cron 的输出
Oct 14 09:10:01 vm1 CROND[11862]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 09:20:01 vm1 CROND[11968]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 09:22:01 vm1 CROND[12004]: (root) CMD (. ~/.restic.env ; /usr/local/bin/restic backup --files-from=/root/restic.files --tag automated 2>> ~/restic.err >> ~/restic.log)
Oct 14 09:30:01 vm1 CROND[12091]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 09:40:01 vm1 CROND[12197]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 09:50:01 vm1 CROND[12304]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 09:58:37 vm1 crond[5026]: (CRON) INFO (Shutting down)
Oct 14 09:58:37 vm1 crond[12493]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 26% if used.)
Oct 14 09:58:37 vm1 crond[12493]: (CRON) INFO (running with inotify support)
Oct 14 09:58:37 vm1 crond[12493]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
Oct 14 09:59:01 vm1 CROND[12504]: (root) CMD (. ~/.restic.env ; /usr/local/bin/restic backup --files-from=/root/restic.files --tag automated 2>> ~/restic.err >> ~/restic.log)
Oct 14 10:00:01 vm1 CROND[12529]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 14 10:01:01 vm1 CROND[12550]: (root) CMD (run-parts /etc/cron.hourly)
Oct 14 10:01:01 vm1 run-parts(/etc/cron.hourly)[12550]: starting 0anacron
Oct 14 10:01:01 vm1 run-parts(/etc/cron.hourly)[12561]: finished 0anacron
Oct 14 10:01:01 vm1 run-parts(/etc/cron.hourly)[12550]: starting mcelog.cron
Oct 14 10:01:01 vm1 run-parts(/etc/cron.hourly)[12569]: finished mcelog.cron
设置 cron 作业我在哪里犯了错误?
谢谢您的帮助。