Linux Cron作业未执行预期任务

Linux Cron作业未执行预期任务,linux,cron,command-line-interface,backup,Linux,Cron,Command Line Interface,Backup,为了备份数据,我设置了一个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

为了备份数据,我设置了一个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 crond

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
文件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作业时犯了错误


谢谢你的帮助。

我发现了错误。正确的路径是/usr/bin/restic,而不是/usr/bin/local/restic