sudo crontab -e允许我编辑crontab,并输入以下内容:
# Hourly backup
0 * * * * rsnapshot hourly
# Daily backup
0 2 * * * rsnapshot daily
# Weekly backup
0 4 * * 6 rsnapshot weekly但它不起作用。我将其更改为对r快照使用完整路径,但仍然无法工作。我在某个地方读到了一些关于cron.d的内容,所以我去了/etc/cron.d/并找到了一个名为r快照的文件。看起来是这样的:
#0 */4 * * * root /usr/bin/rsnapshot hourly
#30 3 * * * root /usr/bin/rsnapshot daily
#0 3 * * 1 root /usr/bin/rsnapshot weekly
#30 2 1 * * root /usr/bin/rsnapshot monthly奇怪的是,据我所知,我从来没有通过r快照进行每月备份。不管怎么说,不要评论我需要的那些。
我添加了一个通过sudo crontab -e进行测试的行,但是cat /etc/cron.d/rsnapshot没有反映任何更改,但是测试过程(回显到.txt)似乎有效。为什么我的后援不起作用?当我在终端机做sudo rsnapshot hourly时,它似乎工作得很好。
还有,为什么时间表和我放的不一样?这个文件甚至与crontab相关吗?
发布于 2016-04-14 19:13:43
"System“cron作业是通过/etc/crontab文件运行的,而不是通过root用户的crontab文件/var/spool/cron/crontabs/root运行的,这是sudo crontab -e编辑的。我的Ubuntu14.04.3系统上的/etc/crontab是(注意信息丰富的#comments):
# /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
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 )
#发布于 2016-04-28 15:20:18
我把事情搞糊涂了。/etc/cron.d/r快照文件随r快照包而来,它不是由crontab命令创建的(因此,它有一个不同的时间表)。根本不需要使用crontab命令,只需编辑/etc/cron.d/r快照,就可以了。
https://askubuntu.com/questions/757413
复制相似问题