LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   NFS and Cron jobs (https://www.linuxquestions.org/questions/linux-networking-3/nfs-and-cron-jobs-338760/)

dgermann 06-30-2005 11:46 AM

NFS and Cron jobs
 
Hi--

Now that my new box is up and running I have set up some cron jobs to do some backups from some NFS shares. Only they are not getting made. Can you help me figure out what is going on?

Yes, I can access the shared NFS filesystem on the new box.

Here is the only error message from /var/log/messages that looks to me to have anything to do with cron and nfs--this was at the time I mounted the nfs shares on the new computer (The new box is named "bak"):
Code:

/var/log/messages:
Jun 29 21:34:30 bak kernel: nfs warning: mount version older than kernel

Here is my /etc/crontab:
Code:

# /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.
# This file also has a username field, 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    run-parts --report /etc/cron.hourly
25 6    * * *  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.monthly

## added by ddg, 2005/06/29:

01 9,11,13,15,17,19 * * *      root run-parts /etc/cron.hourly/bkhourod
01 10,12,14,16,18 * * *        root run-parts /etc/cron.hourly/bkhourev
02 4 * * 1,3,5                  root run-parts /etc/cron.daily/bkdaily1
02 4 * * 0,2,4,6                root run-parts /etc/cron.daily/bkdaily2
22 4 * * 0                      root run-parts /etc/cron.weekly/bkweekly
42 4 1 * *                      root run-parts /etc/cron.monthly/bkmonthly

Here is /etc/cron.hourly/bkhourod:
Code:

/etc/cron.hourly/bkhourod:

#!/bin/sh
set $(date)
  filename="/backups/hourly`date +'%H'`.tgz"
      tar cvfz /$filename /sam/vol22/data /sam/vol22/comm/tap /sam/doug2/all-y /sam/etc
            exit

            #

Finally, here is another excerpt from /var/log/messages:
Code:

More /var/log/messages:
Jun 30 03:48:34 bak -- MARK --
Jun 30 04:08:34 bak -- MARK --
Jun 30 04:28:34 bak -- MARK --
Jun 30 04:48:34 bak -- MARK --
Jun 30 05:08:34 bak -- MARK --
Jun 30 05:28:34 bak -- MARK --
Jun 30 05:48:34 bak -- MARK --
Jun 30 06:08:34 bak -- MARK --
Jun 30 06:25:29 bak syslogd 1.4.1#14ubuntu4: restart.
Jun 30 06:48:34 bak -- MARK --
Jun 30 07:08:34 bak -- MARK --
Jun 30 07:28:34 bak -- MARK --

So it looks to me from those times that cron is doing something at (some of) the appointed times. I do not know where to look for the output of those first few cron jobs, to see if anything is actually getting done.

What do you see? How might I get this to work?

Matir 06-30-2005 02:20 PM

Can you run the scripts sucessfully directly from the command line?

I am not sure what the point of "set $(date)" is.

Matir 06-30-2005 02:21 PM

Oops, I just noticed the bigger problem: why are you using run-parts with the name of a script? run-parts is supposed to take the name of a directory. To just run a single script, omit run-parts.

dgermann 06-30-2005 06:30 PM

David--

Thanks!

OK, I will take out the run-parts parts. :D Never knew what that was for, so I was just copying.

Am running one of the scripts right now and it seems to be working.

Will report back.

David, thank you very much!

Matir 06-30-2005 07:29 PM

No problem.

run-parts runs all scripts contained in a directory. I believe it parallelizes execution, but that I am not sure of.

dgermann 07-01-2005 10:34 AM

David--

Thanks!

Well, I have it working, sort of.

I took out the parts about run-parts, then found that the bkhourev was running each hour. So I commented out the first four cron jobs, the ones the distro had inserted there.

Do you have any idea what those four jobs are doing, and if I should not have commented them out? They are:

Code:

17 *    * * *  root    run-parts --report /etc/cron.hourly
25 6    * * *  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *  root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.monthly


Matir 07-01-2005 10:46 AM

Those jobs are running all your "normal" routine cron jobs.... If you don't have any other jobs (including, for example, updates of the 'locate' database) then this is not a problem. I would leave them in, myself.

Everything in /etc/cron.hourly is supposed to be run EVERY hour. Everything in /etc/cron.weekly is supposed to be run each week, and so forth.

dgermann 07-01-2005 08:57 PM

David--

OK, I get it. I think.

I could set up my own directory, say cron.doug, and put all my special stuff in there, and run it as I wish.

That's why when I put in cron.hourly fileA to be run on even hours from 9 am to 7 pm and another to run on odd hours, were getting run every hour, around the clock, right? Except only one of those two was being run.

Thanks, David! You are a good teacher. :)

Matir 07-01-2005 09:02 PM

That's exactly why it was occuring.

You can actually use the crontab utility to install cronjobs of your own as you want, to run any script.

dgermann 07-05-2005 10:38 PM

Thanks, David!

Thanks to your help I was able to get it going. :D

Pretty much all is well!


All times are GMT -5. The time now is 11:21 AM.