Loading ...
Sorry, an error occurred while loading the content.

drivertodrivercp modified but not running from crontab

Expand Messages
  • peecock41
    In order to get the backup working from disk 1 to disk 2 under unslung 2.12 I installed rsync and modified /usr/sbin/drivertodrivercp to use it. Here s the
    Message 1 of 6 , Dec 15, 2004
    • 0 Attachment
      In order to get the backup working from disk 1 to disk 2 under unslung
      2.12 I installed rsync and modified /usr/sbin/drivertodrivercp to use it.

      Here's the modified snippet of drivertodrivercp

      ---
      touch /tmp/DriveBackuping
      #/usr/sbin/drive_backup --delete /share/hdd/conf/ /share/flash/conf/
      #/usr/sbin/drive_backup --copy /share/hdd/conf/ /share/flash/conf/
      /opt/bin/rsync -a --delete --delete-after /share/hdd/conf/
      /share/flash/conf
      if [ $? = 0 ]; then
      /opt/bin/rsync -a --delete --delete-after /share/hdd/data/
      /share/flash/data
      fi
      ---
      (Note: the rsync lines run on to the next line)

      If I run this drivertodrivercp by hand it works fine, if I let it run
      through /etc/crontab it exits without doing anything.

      Why doesn't it want to run properly through the crontab?

      Thanks for any help,

      Albert
    • unix fan
      What does your crontab entry say (i.e., what s the output of crontab -l ?) ... __________________________________________________ Do You Yahoo!? Tired of
      Message 2 of 6 , Dec 15, 2004
      • 0 Attachment
        What does your crontab entry say
        (i.e., what's the output of "crontab -l" ?)


        --- peecock41 <peecock41@...> wrote:

        >
        > In order to get the backup working from disk 1 to
        > disk 2 under unslung
        > 2.12 I installed rsync and modified
        > /usr/sbin/drivertodrivercp to use it.
        >
        > Here's the modified snippet of drivertodrivercp
        >
        > ---
        > touch /tmp/DriveBackuping
        > #/usr/sbin/drive_backup --delete /share/hdd/conf/
        > /share/flash/conf/
        > #/usr/sbin/drive_backup --copy /share/hdd/conf/
        > /share/flash/conf/
        > /opt/bin/rsync -a --delete --delete-after
        > /share/hdd/conf/
        > /share/flash/conf
        > if [ $? = 0 ]; then
        > /opt/bin/rsync -a --delete --delete-after
        > /share/hdd/data/
        > /share/flash/data
        > fi
        > ---
        > (Note: the rsync lines run on to the next line)
        >
        > If I run this drivertodrivercp by hand it works
        > fine, if I let it run
        > through /etc/crontab it exits without doing
        > anything.
        >
        > Why doesn't it want to run properly through the
        > crontab?
        >
        > Thanks for any help,
        >
        > Albert
        >
        >
        >
        >


        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com
      • Rod Whitby
        ... Normally, the reason for things failing in crontab when they work on command line is due to the very minimal environment variables that crontab sets up
        Message 3 of 6 , Dec 15, 2004
        • 0 Attachment
          On Wed, 15 Dec 2004 20:35:49 -0000, peecock41 <peecock41@...> wrote:
          > If I run this drivertodrivercp by hand it works fine, if I let it run
          > through /etc/crontab it exits without doing anything.
          >
          > Why doesn't it want to run properly through the crontab?

          Normally, the reason for things failing in crontab when they work on
          command line is due to the very minimal environment variables that
          crontab sets up (i.e. not even HOME is usually available).

          But I can't see how that would affect rsync ....

          -- Rod
        • peecock41
          ... Actually, the first four lines of /etc/crontab read: SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO= HOME=/ So the environment should be
          Message 4 of 6 , Dec 15, 2004
          • 0 Attachment
            --- In nslu2-general@yahoogroups.com, Rod Whitby <unslung@g...> wrote:
            > On Wed, 15 Dec 2004 20:35:49 -0000, peecock41 <peecock41@y...> wrote:
            > > If I run this drivertodrivercp by hand it works fine, if I let it run
            > > through /etc/crontab it exits without doing anything.
            > >
            > > Why doesn't it want to run properly through the crontab?
            >
            > Normally, the reason for things failing in crontab when they work on
            > command line is due to the very minimal environment variables that
            > crontab sets up (i.e. not even HOME is usually available).
            >
            > But I can't see how that would affect rsync ....
            >
            > -- Rod

            Actually, the first four lines of /etc/crontab read:

            SHELL=/bin/sh
            PATH=/sbin:/bin:/usr/sbin:/usr/bin
            MAILTO=""
            HOME=/

            So the environment should be allright. And I use the full path to
            rsync, I even tried the option --no-detach but that didn't make a
            difference.

            Albert
          • Rod Whitby
            ... Maybe you could use the strace command (there s an ipk for it) and redirect the output to a log file. Then you can see what s happening when crontab runs
            Message 5 of 6 , Dec 15, 2004
            • 0 Attachment
              On Wed, 15 Dec 2004 22:01:05 -0000, peecock41 <peecock41@...> wrote:
              > So the environment should be allright. And I use the full path to
              > rsync, I even tried the option --no-detach but that didn't make a
              > difference.

              Maybe you could use the strace command (there's an ipk for it) and
              redirect the output to a log file. Then you can see what's happening
              when crontab runs it.

              -- Rod
            • peecock41
              ... I got it working! The relevant entry in /etc/crontab is 40 19 * * * root /usr/sbin/drivertodrivercp & /dev/null (as created by the webinterface). However
              Message 6 of 6 , Dec 16, 2004
              • 0 Attachment
                --- In nslu2-general@yahoogroups.com, Rod Whitby <unslung@g...> wrote:
                > On Wed, 15 Dec 2004 22:01:05 -0000, peecock41 <peecock41@y...> wrote:
                > > So the environment should be allright. And I use the full path to
                > > rsync, I even tried the option --no-detach but that didn't make a
                > > difference.
                >
                > Maybe you could use the strace command (there's an ipk for it) and
                > redirect the output to a log file. Then you can see what's happening
                > when crontab runs it.
                >
                > -- Rod

                I got it working!

                The relevant entry in /etc/crontab is

                40 19 * * * root /usr/sbin/drivertodrivercp &>/dev/null

                (as created by the webinterface). However if I remove the &>/dev/null
                part it works fine!

                Unfortunately, the webinterface always put the &>/dev/null behind it,
                so whenever I change the backuptime I have to something else I have to
                edit the /etc/crontab by hand.

                The trick is to send the output of rsync in the drivertodrivercp
                script to /dev/null explicitly (i.e. &>/dev/null at the end of the
                command).

                Albert
              Your message has been successfully submitted and would be delivered to recipients shortly.