LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron backup job fails to run (https://www.linuxquestions.org/questions/linux-newbie-8/cron-backup-job-fails-to-run-854367/)

bluethundr 01-05-2011 08:55 AM

cron backup job fails to run
 
hey LQ!

long time no hear! :) I'm having a small issue where the backup jobs
that I set to run in the crontab of the backup user do not appear to
be running. Here's how I set it up (with crontab -e as the backup
user):

run amanda every night (check at 2:45 and backup at 3)
Code:

45 2 * * * /usr/sbin/amcheck 1>>  /var/log/amanda/crontab/amcheck.log
* 3 * * * /usr/sbin/amdump  1>> /var/log/amanda/crontab/amdump.log

The executables are where they are supposed to be and run if you type
them in on the command line:

Code:

[amandabackup@amanda ~]$ ls -l /usr/sbin/amcheck
-rwsr-x--- 1 root disk 68624 Dec 29 14:08 /usr/sbin/amcheck

and

Code:

[amandabackup@amanda ~]$ ls -l /usr/sbin/amdump
-rwxr-xr-x 1 amandabackup disk 9637 Dec 29 14:08 /usr/sbin/amdump

both do actually work!

Although I'm not sure what the 's' indicates in the permissions of amcheck.


And here's a tail of the cron logs

Code:

[root@amanda init.d]# tail /var/log/cron
Jan  5 07:01:01 newamanda crond[13612]: (root) CMD (run-parts /etc/cron.hourly)
Jan  5 07:17:09 newamanda crontab[13652]: (amandabackup) BEGIN EDIT
(amandabackup)
Jan  5 07:18:00 newamanda crontab[13652]: (amandabackup) REPLACE (amandabackup)
Jan  5 07:18:00 newamanda crontab[13652]: (amandabackup) END EDIT (amandabackup)
Jan  5 07:18:01 newamanda crond[1448]: (amandabackup) RELOAD (cron/amandabackup)
Jan  5 07:18:39 newamanda crond[13686]: (CRON) STARTUP (V5.0)
Jan  5 07:23:01 newamanda crontab[13699]: (amandabackup) BEGIN EDIT
(amandabackup)
Jan  5 07:23:47 newamanda crontab[13699]: (amandabackup) END EDIT (amandabackup)
Jan  5 07:25:38 newamanda crontab[13751]: (amandabackup) BEGIN EDIT
(amandabackup)
Jan  5 07:25:53 newamanda crontab[13751]: (amandabackup) END EDIT (amandabackup)

And the cron daemon is running:

Code:

bluethundr@amanda:~/rpm$ sudo ps -ef | grep cron
root    13686    1  0 07:18 ?        00:00:00 crond
1001    14318 14274  0 09:51 pts/3    00:00:00 grep --color=auto cron

I would certainly appreciate any thoughts on this situation that you might be willing to share!

:)

Reuti 01-05-2011 09:21 AM

Some remarks:

Code:

* 3 * * *
will mean each minute from 03:00 to 03:59. If it should happen only one time, the minute must be specified.

Code:

[amandabackup@amanda ~]$ ls -l /usr/sbin/amcheck
-rwsr-x--- 1 root disk 68624 Dec 29 14:08 /usr/sbin/amcheck

The 's' means "set uid" and it will run as the root user, even when it's started by an ordinary user. To check that cron on its own is working fine, can you define a script:

Code:

#!/bin/sh
date >> $HOME/logfile

(make it executable) and check the output? To test this the above rule with an asterisk for the minute is perfect.

ptader 01-05-2011 12:42 PM

Some more considerations:

Your command...

[root@amanda init.d]# tail /var/log/cron

...doesn't show us the relevant time from the cron log file. In other words, your tail starts with the time 07:01:01 A.M., but the time we need to see is around 2:45 - 4am. If that time frame isn't in the current cron log file, it might have been rotated out. Look for files like cron.1, cron.2 and look (more, less, cat, etc.) through those files.

Second, did the cron job create a /var/log/amanda/crontab/amcheck.log or /var/log/amanda/crontab/amdump.log file? What's in them?

Hoping that helps...

choogendyk 01-05-2011 08:33 PM

Just a couple of comments.

Presuming you work in the daytime, there is not much point in running amcheck at 2:45am and then running amdump at 3:00am (assuming you meant to do "0 3 * * *"), since there is no one around to respond to the amcheck. Typically, you would run amcheck around 15:00 in the afternoon so that you can do something about any issues there might be and not have an amdump fail in the middle of the night.

Second, is your configuration actually named "1"? amcheck and amdump take at least the name of the configuration as an argument. Typically, that would be something like "daily", and your command would be `amcheck daily`.

Third, you are routing the output to /var/log/amanda/crontab/amcheck.log and amdump.log. Is there anything in those files after your run? I'm inclined to think not, because amcheck and amdump, when run from cron, typically spawn off as daemon like processes and send you a report by email. Your email should be in the amanda.conf in the configuration directory.

Can you tell us anything about your installation and configuration of Amanda?

Reuti 01-06-2011 03:35 AM

Quote:

Originally Posted by choogendyk (Post 4214657)
Second, is your configuration actually named "1"?

AFAICS the 1>> is the same like >> and referring to stdout. So this should be fine.

choogendyk 01-06-2011 05:50 AM

Quote:

Originally Posted by Reuti (Post 4214959)
AFAICS the 1>> is the same like >> and referring to stdout. So this should be fine.

Of course. I was looking for the required argument and missed the lack of a space there. Typically, one wouldn't need or put the 1 there, since it is assumed.

Anyway, that clarifies that the commands are missing the required argument, which is the name of the configuration that they are to run. Since they are designed to run in background from cron and send reports via email, I would just get rid of all the extraneous >> stuff.


All times are GMT -5. The time now is 12:33 PM.