Announcement

Collapse
No announcement yet.

Something strange here . . .

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Something strange here . . .

    Good Day All . . .

    This is a bit of everything and it seems to have happened since I installed 7.04.

    I have a bash script that runs hourly on a Kcron job. It takes the new files from my personal area, /home and using rsync -avu copies them to a daily directory on two of my noauto,exec,user removable hard drives (No UUID in use) in the same box and logs the results.

    I mount the drive, copy the files then unmount the drive. This is done twice.

    The problem is that the second or last hard drive partition does not unmount on a Kcron job.

    If I manually 'Run Now' in Kcron then both drive partitions are mounted and properly unmounted.

    I have moved the cron job from user to root and reversed the two storage drives to see if a hardware problem is present but the problem is still exists.

    Here are some observations:

    1. The first run of the day captures the date and creates a new directory in storage drive one and transfers all the files in /home as it should. The log file shows that the second drive is mounted but the dated directory is the only footprint left. No files are transferred and the exit error routine is not activated.

    2. Subsequent runs unmount the drives first. This is a less then graceful way of exiting if the drives are in use. The files are copied to storage drive one but my error routine kicks in when the script cannot save to storage drive two. A user mounted the drive but that same user cannot unmount the drive via a cron job but can unmount it if run as a standalone script in a terminal.

    I have checked all the permissions and all the stats but nothing shows up. I have gone through the mount and umount help but no command line argument works.

    I cannot divide then up into two scripts because the first run of the day may take 30 - 45 minutes to run while subsequent runs take only about ten seconds and I want them on an hourly basis.

    Anyone point me in a new direction?

    Thanks . . .

    #2
    Re: Something strange here . . .

    I'd suggest creating a verbose log to show exactly what's going on, i.e. messages telling what action is taken and if it executed properly.
    For external use only.

    Comment


      #3
      Re: Something strange here . . .

      Originally posted by PMB
      The problem is that the second or last hard drive partition does not unmount on a Kcron job.
      If the first unmount command worked and the second failed, I'd search this (latter one) for errors, e.g. typos ...

      Comment


        #4
        Re: Something strange here . . .

        Thanks for the replies.

        Bring you up to speed.

        UnicornRider, sorry. That is not possible since it is a two step loop. Loop runs storage drive one and then runs again with storage drive two.

        SheeEttin, you may have inadvertently put me on the right track. My code was heavily echoed >> to a log file but I missed some lines. So on your suggestion I echoed >> every line and I changed the timing of the Kcron job to every five minutes.

        The problem went away. I don't know why but it no longer appeared.

        I commented # out the added >>s and the problem reappeared.

        The only thing that I surmised was that the >> log files were time consuming. Maybe the script is running too fast and code is still being processed when the umount command is given. Maybe . . .

        I added sleep 10 after the rsync copy line and before the umount command. The problem went away. Everything unmounts.

        The last file to be processed is a 143mb data file. This could take a longer time to copy. The one screwup point here is that it only gets copied once on first run and generally not after.

        I know it is not code related. I know it is not hardware related. I think that only leaves everything else.

        I have probably solved the problem but I still don't know what the problem was. There are still some observations that don't fit the solution but what the hell it works!

        Thanks again.

        Comment


          #5
          Re: Something strange here . . .

          Yeah, I was suspecting that. You can use "umount -l", the "lazy unmount", which causes umount to wait until the file system is no longer used to unmount it.

          As for the file copy failing after the first time, you might want to look at the man page for rsync, especially the -u option. (There doesn't seem to be an equivalent for the -f option of cp... is this default behavior?)
          For external use only.

          Comment

          Working...
          X