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

Re: Problems with cron

Expand Messages
  • Daniel Berenguer
    ... Thank you very much! crontab crotab_file did the trick. Daniel.
    Message 1 of 10 , Aug 1 11:18 AM
    • 0 Attachment
      --- In nslu2-general@yahoogroups.com, "bascule_the_fule" <sean@...> wrote:
      >
      > --- In nslu2-general@yahoogroups.com, "Daniel Berenguer"
      > <dberenguer@> wrote:
      > >
      > > I installed CRON onto my OpenSlug (ipkg install cron) but the install
      > > process didn't create /etc/crontab. Then I created /etc/crontab
      > > containing this:
      > >
      > > SHELL=/bin/sh
      > >
      > > # m h dom mon dow user command
      > >
      > > # Synchronize date/time with remote server
      > > 0 0 * * * root /home/root/syncdate
      > >
      > > This crontab is supposed to run syncdate at 00:00 every day but it
      > > doesn't work.
      >
      > Why not run 'crontab -e' as root and create an entry like this:
      >
      > # Synchronize date/time with remote server
      > 0 0 * * * /home/root/syncdate
      >
      > ... having checked that the command '/home/root/syncdate' executes
      > with the expected results first?
      >
      > BTF
      >

      Thank you very much!

      crontab crotab_file did the trick.

      Daniel.
    • Daniel Berenguer
      ... install ... ... However, cron can only run scripts out of /home (ex: /etc/syncdate). Anyone knows why? Daniel.
      Message 2 of 10 , Aug 2 1:35 AM
      • 0 Attachment
        --- In nslu2-general@yahoogroups.com, "Daniel Berenguer"
        <dberenguer@...> wrote:
        >
        > --- In nslu2-general@yahoogroups.com, "bascule_the_fule" <sean@> wrote:
        > >
        > > --- In nslu2-general@yahoogroups.com, "Daniel Berenguer"
        > > <dberenguer@> wrote:
        > > >
        > > > I installed CRON onto my OpenSlug (ipkg install cron) but the
        install
        > > > process didn't create /etc/crontab. Then I created /etc/crontab
        > > > containing this:
        > > >
        > > > SHELL=/bin/sh
        > > >
        > > > # m h dom mon dow user command
        > > >
        > > > # Synchronize date/time with remote server
        > > > 0 0 * * * root /home/root/syncdate
        > > >
        > > > This crontab is supposed to run syncdate at 00:00 every day but it
        > > > doesn't work.
        > >
        > > Why not run 'crontab -e' as root and create an entry like this:
        > >
        > > # Synchronize date/time with remote server
        > > 0 0 * * * /home/root/syncdate
        > >
        > > ... having checked that the command '/home/root/syncdate' executes
        > > with the expected results first?
        > >
        > > BTF
        > >
        >
        > Thank you very much!
        >
        > crontab crotab_file did the trick.
        >
        > Daniel.
        >

        ... However, cron can only run scripts out of /home (ex:
        /etc/syncdate). Anyone knows why?

        Daniel.
      • Sean Gibbins
        Daniel Berenguer wrote: ... Is there anything logged as a result of the failure to run? Check the permissions of the script you are trying to execute, and
        Message 3 of 10 , Aug 2 2:18 AM
        • 0 Attachment
          Daniel Berenguer wrote: >

          > > crontab crotab_file did the trick.
          >
          > ... However, cron can only run scripts out of /home (ex:
          > /etc/syncdate). Anyone knows why?
          >





          Is there anything logged as a result of the failure to run?

          Check the permissions of the script you are trying to execute, and try
          to execute it on the command line while logged in* as the user whose
          crontab defines the schedule for running it in the location where it
          fails, as I suspect it will come down to permissions or something else
          related to the identity of the user trying to execute the script.

          There is some crontab troubleshooting advice that might be useful here:

          http://en.wikipedia.org/wiki/Crontab

          HTH

          Sean

          * alternatively 'su - <user>' to ensure that you are using the same
          environment as cron will use when it attempts to run the script
        • Daniel Berenguer
          ... Same result Sean. And the script runs OK manually. Should I set maybe any environment variable? Thanks again, Daniel.
          Message 4 of 10 , Aug 2 11:58 AM
          • 0 Attachment
            --- In nslu2-general@yahoogroups.com, Sean Gibbins <sean@...> wrote:
            >
            > Daniel Berenguer wrote: >
            >
            > > > crontab crotab_file did the trick.
            > >
            > > ... However, cron can only run scripts out of /home (ex:
            > > /etc/syncdate). Anyone knows why?
            > >
            >
            >
            >
            >
            >
            > Is there anything logged as a result of the failure to run?
            >
            > Check the permissions of the script you are trying to execute, and try
            > to execute it on the command line while logged in* as the user whose
            > crontab defines the schedule for running it in the location where it
            > fails, as I suspect it will come down to permissions or something else
            > related to the identity of the user trying to execute the script.
            >
            > There is some crontab troubleshooting advice that might be useful here:
            >
            > http://en.wikipedia.org/wiki/Crontab
            >
            > HTH
            >
            > Sean
            >
            > * alternatively 'su - <user>' to ensure that you are using the same
            > environment as cron will use when it attempts to run the script
            >

            Same result Sean. And the script runs OK manually.

            Should I set maybe any environment variable?

            Thanks again,

            Daniel.
          • John
            ... Yes. PATH is an important one, e.g. export PATH=/bin:/usr/bin:/opt/bin:/usr/local/bin but change this to insert whatever path your script needs. Cron
            Message 5 of 10 , Aug 2 12:20 PM
            • 0 Attachment
              > Should I set maybe any environment variable?

              Yes. PATH is an important one, e.g.

              export PATH=/bin:/usr/bin:/opt/bin:/usr/local/bin

              but change this to insert whatever path your script needs.

              Cron starts jobs with only specific environment variables set.
              Anything else that your job needs must be set explicitly. This is
              a security measure designed to prevent a hostile user from
              capturing control of someone else's cron job.
            • Daniel Berenguer
              ... John, I m using absolute paths in my crontab. Should I add the PATH variable anyway? Thanks, Daniel.
              Message 6 of 10 , Aug 2 1:56 PM
              • 0 Attachment
                --- In nslu2-general@yahoogroups.com, John <jl.050877@...> wrote:
                >
                > > Should I set maybe any environment variable?
                >
                > Yes. PATH is an important one, e.g.
                >
                > export PATH=/bin:/usr/bin:/opt/bin:/usr/local/bin
                >
                > but change this to insert whatever path your script needs.
                >
                > Cron starts jobs with only specific environment variables set.
                > Anything else that your job needs must be set explicitly. This is
                > a security measure designed to prevent a hostile user from
                > capturing control of someone else's cron job.
                >

                John, I'm using absolute paths in my crontab. Should I add the PATH
                variable anyway?

                Thanks,

                Daniel.
              • John
                Daniel, ... Do the programs that you are running in crontab need the PATH variable in order to run other programs? Many unix programs call/run other unix
                Message 7 of 10 , Aug 2 2:39 PM
                • 0 Attachment
                  Daniel,

                  > John, I'm using absolute paths in my crontab. Should I add the PATH
                  > variable anyway?

                  Do the programs that you are running in crontab need the PATH
                  variable in order to run other programs? Many unix programs
                  call/run other unix programs.

                  The example you gave was /etc/syncdate. I don't know what
                  that is but, from the name alone, it seems quite possible that its
                  operation depends on being able to find another program in the path
                  such as rdate or ntpdate or ntpd or similar.

                  If things are set up right, any output from the cron job
                  should be mailed to you. Do you get any error messages from the
                  cron job?

                  John
                • Daniel Berenguer
                  ... Hi John. Setting PATTH makes no differrence so far. I m even testing with more simple crontabs and most of the times they don t work. Ex: SHELL=/bin/sh
                  Message 8 of 10 , Aug 4 8:12 AM
                  • 0 Attachment
                    --- In nslu2-general@yahoogroups.com, John <jl.050877@...> wrote:
                    >
                    > Daniel,
                    >
                    > > John, I'm using absolute paths in my crontab. Should I add the PATH
                    > > variable anyway?
                    >
                    > Do the programs that you are running in crontab need the PATH
                    > variable in order to run other programs? Many unix programs
                    > call/run other unix programs.
                    >
                    > The example you gave was /etc/syncdate. I don't know what
                    > that is but, from the name alone, it seems quite possible that its
                    > operation depends on being able to find another program in the path
                    > such as rdate or ntpdate or ntpd or similar.
                    >
                    > If things are set up right, any output from the cron job
                    > should be mailed to you. Do you get any error messages from the
                    > cron job?
                    >
                    > John

                    Hi John.

                    Setting PATTH makes no differrence so far. I'm even testing with more
                    simple crontabs and "most of the times" they don't work. Ex:

                    SHELL=/bin/sh
                    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin

                    0 0 * * * echo "hello!" >> /home/hello.txt

                    At 00:00 sometimes hello.txt is created and edited and sometimes not.
                    I'm plying with the system time in order to do my tests and this is
                    maybe somehow causing problems, but I'm not sure.

                    Now I realize that pointing to a script placed in /home or /etc
                    doesn't make any difference either.

                    ... I'm continuing with my tests...

                    Thank you very much,

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