[SOLVED] crontab won't run rsnapshot

Issues related to applications and software problems
Post Reply
altiris
Posts: 334
Joined: 2013/05/31 01:27:50

[SOLVED] crontab won't run rsnapshot

Post by altiris » 2015/02/18 14:19:06

I understand rsnapshot is not supported but maybe I am doing something wrong within cron/crontab. I am trying to get rsnapshot to be automated to run via /etc/crontab. My /etc/crontab file looks like this

Code: Select all

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# 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
# crontab for rsnapshot
00	01	*	*	mon     /usr/bin/rsnapshot -c /etc/rsnapshot/backup1 weekly
00	02	*	*	*	    /usr/bin/rsnapshot -c /etc/rsnapshot/backup2 daily
Altneratively, I have tried taking out the /usr/bin/rsnapshot command and putting the location of an executable .sh file which contains

Code: Select all

#!/bin/sh
/usr/bin/rsnapshot -c /etc/rsnapshot/backup2 daily
However I still can not get it to run. My rsnapshot log only has logged whenever I run the command manually so this means that cron or crontab (idk which) is not even running the commands. I have looked in all of my cron logs in /var/log and there is nothing pertaining to rsnapshot or my .sh files.
EDIT: My config now has the .sh files in them instead of rsnapshot as a permanant thing. I noticed my .sh files were not chmoded 644 and I read this fixed an issue for someone on these forums with crontab running scripts/files. Hopefully that may fix it although Id still like confirmation everything in crontab is okay.
Last edited by altiris on 2015/02/28 18:13:11, edited 1 time in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: crontab won't run rsnapshot

Post by gerald_clark » 2015/02/18 17:25:50

Please read the comments at the top of the crontab. You are using the user crontab format, not the /etc/crontab format.

altiris
Posts: 334
Joined: 2013/05/31 01:27:50

Re: crontab won't run rsnapshot

Post by altiris » 2015/02/21 17:57:16

gerald_clark wrote:Please read the comments at the top of the crontab. You are using the user crontab format, not the /etc/crontab format.
Are you referring to "For details see man 4 crontabs"? If so then what I got from that was that I should be using anacron instead of cron? Ive referred myself to man 8 anacrontab and then I also looked at man 5 anacrontab. So am I supposed to be using anacron instead?

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: crontab won't run rsnapshot

Post by TrevorH » 2015/02/21 17:59:29

No, he's referring to the comments that you posted regarding the *six* fields that need to be present in this version of the crontab. Here they are again, look closely at the last one. It's missing in yours.
# 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
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

altiris
Posts: 334
Joined: 2013/05/31 01:27:50

Re: crontab won't run rsnapshot

Post by altiris » 2015/02/21 18:47:10

TrevorH wrote:No, he's referring to the comments that you posted regarding the *six* fields that need to be present in this version of the crontab. Here they are again, look closely at the last one. It's missing in yours.
# 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
Oh the username? I was following this https://www.centos.org/docs/5/html/5.2/ ... uring.html and so I made a separate directory for each rsnapshot backup and put an executable file (basically sh file except no .sh extension as I read that may not work) in each directory. In each script file I just have this

Code: Select all

#!/bin/sh
/usr/bin/rsnapshot -c /etc/rsnapshot/custombackup.conf weekly
So I have two backup jobs so there are two directories and one script per directory. my /etc/crontab looks like this now,

Code: Select all

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# 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$
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
00 01 * * mon root run-parts /etc/cron.rsnapshot_custombackup
00 02 * * *   root run-parts /etc/cron.rnsapshot_servers
I guess this seems kind of confusing, I kind of like it this way personally. If there are any recommendations or things that I am doing wrong please point them out. I think I got this time though, I guess I can wait for those to be executed or change the time and see for myself now.

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: crontab won't run rsnapshot

Post by AlanBartlett » 2015/02/21 19:33:16

No. Even that is wrong! You now have eight fields on each line. Please look again at the commented out header of the file, it shows seven fields.
Image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

altiris
Posts: 334
Joined: 2013/05/31 01:27:50

Re: crontab won't run rsnapshot

Post by altiris » 2015/02/28 02:42:18

AlanBartlett wrote:No. Even that is wrong! You now have eight fields on each line. Please look again at the commented out header of the file, it shows seven fields.
Ugh I just can't do this thing correctly can I, I have to remove "run-parts"? Then it will be correct?

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: crontab won't run rsnapshot

Post by TrevorH » 2015/02/28 14:10:11

I believe your last posted crontab entry was correct. It needs at least 7 fields and anything more than 7 will be passed to the 7th as parameters.

I use rsnapshot and do it a different way. I have entries in the root user's crontab like so

Code: Select all

# crontab -l
# HEADER: This file was autogenerated at Thu May 24 08:51:50 +0000 2012 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: rsnapshot.hourly
0 5,18,23 * * * /usr/bin/rsnapshot hourly
# Puppet Name: rsnapshot.daily
0 1 * * * /usr/bin/rsnapshot daily
# Puppet Name: rsnapshot.weekly
0 3 * * 6 /usr/bin/rsnapshot weekly
# Puppet Name: rsnapshot.monthly
0 5 1 * * /usr/bin/rsnapshot monthly
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

altiris
Posts: 334
Joined: 2013/05/31 01:27:50

Re: crontab won't run rsnapshot

Post by altiris » 2015/02/28 18:12:47

TrevorH wrote:I believe your last posted crontab entry was correct. It needs at least 7 fields and anything more than 7 will be passed to the 7th as parameters.

I use rsnapshot and do it a different way. I have entries in the root user's crontab like so

Code: Select all

# crontab -l
# HEADER: This file was autogenerated at Thu May 24 08:51:50 +0000 2012 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: rsnapshot.hourly
0 5,18,23 * * * /usr/bin/rsnapshot hourly
# Puppet Name: rsnapshot.daily
0 1 * * * /usr/bin/rsnapshot daily
# Puppet Name: rsnapshot.weekly
0 3 * * 6 /usr/bin/rsnapshot weekly
# Puppet Name: rsnapshot.monthly
0 5 1 * * /usr/bin/rsnapshot monthly
I think I will stick with my config then? It seems to be working fine, although i guess I could also try removing run-parts and the following directory and just issuing the rnsapshot command, I would assume that would work though and I will just stick with .sh files I guess. Thank you for your help though, I think this is solved then.

Post Reply