Announcement

Collapse
No announcement yet.

Cron Jobs - Runtime Error and more...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cron Jobs - Runtime Error and more...

    Ok, I finally wanted to try and add a crob job through the SiteWorx interface (Simple).

    First of all what is the root of the Script field, I mean do I use

    /home/sitename.sitename.com/html/cgi-bin/myscript.cgi

    or

    /cgi-bin/myscript.cgi

    Since I did not know, I used the latter.


    Anyways I selected to "Every hour" and clicked the "Add" button.

    Now I get a Runtime error:
    A Runtime Error has occured.
    Do you wish to Debug?

    Line 32:
    Error: 'elem' is null or not an object


    Furthermore there is a message in red, in the upper right corner saying:

    Invalid fields: minute, day, month, dayofweek


    Please let me know when this has been fixed, thanks...

  • #2
    Originally posted by RWF
    First of all what is the root of the Script field, I mean do I use

    /home/sitename.sitename.com/html/cgi-bin/myscript.cgi

    or

    /cgi-bin/myscript.cgi
    There isn't a "root" in the sense of web root or document root like Apache. Instead, it uses the $PATH environment variable to find commands. When looking at the Cron Jobs screen in Siteworx, look in the bottom box to see what the PATH variable is set to. If it says Default, then your path will most likely be the server default (unless you've modified your path through the shell). The default is typically:
    /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/<username>/bin

    You won't be able to set your path to include: "/home/sitename.sitename.com/html/" and then use "/cgi-bin/myscript.cgi" as the script. Instead, you'll want to either use the full path to the cgi script (as in your first example), or add "/home/sitename.sitename.com/html/cgi-bin" to your path. I would advise using the full path option, as it is less complicated.


    Originally posted by RWF
    Now I get a Runtime error:
    A Runtime Error has occured.
    Do you wish to Debug?

    Line 32:
    Error: 'elem' is null or not an object
    Sorry, this is a javascript error. It will be fixed shortly.


    Originally posted by RWF
    Furthermore there is a message in red, in the upper right corner saying:

    Invalid fields: minute, day, month, dayofweek

    Please let me know when this has been fixed, thanks...
    This is not a javascript error, but we know what the problem is, and we'll have this fixed shortly as well.

    Thanks,
    Socheat
    Socheat Sou
    InterWorx-CP | http://interworx.com
    InterWorx Control Panel

    Comment


    • #3
      A couple things to note:

      /home/sitename.sitename.com/html/cgi-bin/myscript.cgi
      I assume you mean /home/username/sitename.com/html/cgi-bin/myscript.cgi
      Where username is the first 8 characters of "sitename.com"

      Furthermore there is a message in red, in the upper right corner saying:

      Invalid fields: minute, day, month, dayofweek

      Please let me know when this has been fixed, thanks...
      This looks to me like you left the minute, day, month, and day of week boxes blank. All those fields must be something for it to work. For example, if you wanted the CRON job to run every Hour on the hour, you would choose:

      Hour: Every Hour
      Minute: 0
      Month: Every Month
      Day of Month: Every Day
      Day of Week: Every Day

      Give that a try.

      Paul
      Paul Oehler
      InterWorx-CP | http://interworx.com
      InterWorx Control Panel

      Comment


      • #4
        Paul, using the "Simple" interface with the combo boxed, there is no 0 minute option

        Comment


        • #5
          I'm pretty sure there is, just scroll down in that box.

          Paul
          Paul Oehler
          InterWorx-CP | http://interworx.com
          InterWorx Control Panel

          Comment


          • #6
            Paul, you're right there is a zero, a page down in the option list or so. However that interface should be made a little smarter, so one only had to select one option, and the other where set to default instead of blank, just like it's done in the "Advanced" interface.

            Anyways, I have given up on the "Simple" interface, and is using the "Advanced" interface to add a CRON job that executes every hour.

            However I must have entered the path incorrectly, because I has never been executed, and I know the script works, because I tested it from a terminal.

            Path example that did NOT work:

            /home/sitename/sitename.com/html/cgi-bin/myscript.cgi

            Anyways, I get a runtime error in line 262, after having edited an existing job, actually when pressing the "Save" button. It is a problem that occurs when calling this "onClick="javascript:return confirmPerMinuteCron();"> ". Note that it did seem to accept my change even with the above error.

            My second guess is now this:
            /html/cgi-bin/myscript.cgi

            I suggest a little documentation, when clicking the question mark, could save people some valuable time.

            and if that does not work, then this:
            /cgi-bin/myscript.cgi

            Comment


            • #7
              Your recommendations of clearer documentation and simplified interface for doing things like "every hour on the hour" are noted, thanks for that.

              /home/sitename/sitename.com/html/cgi-bin/myscript.cgi

              Is this myscript.cgi supposed to be executed in a web browser, or at the command line? Specifying the program to run that way will try to execute it as a command line program, and won't work if it is supposed to be executed via a web browser. In order to have CRON execute the script as it would be via a web browser, you could do like:

              lynx --dump http://sitename.com/cgi-bin/myscript.cgi

              If you'd like to e-mail support@interworx.info with your server login information we could help debug the situation (just reference this thread).

              Paul
              Paul Oehler
              InterWorx-CP | http://interworx.com
              InterWorx Control Panel

              Comment


              • #8
                Paul, this is a script that should be run from the command line, I guess.

                It is just a short simple script that clears a .htpasswd file in a certain area, actually the script copies a blank file (blank.txt) to the .htpasswd file.

                This works fine when I run it from a terminal in the cgi-bin folder like this:

                perl myscript.cgi

                However so far I have not been succesful in getting it done ever hour via CRON

                Comment


                • #9
                  This works fine when I run it from a terminal in the cgi-bin folder like this:

                  perl myscript.cgi
                  If this is the case, I'd recommend setting the cron job to run:

                  /usr/bin/perl /home/sitename/sitename.com/html/cgi-bin/myscript.cgi

                  Paul
                  Paul Oehler
                  InterWorx-CP | http://interworx.com
                  InterWorx Control Panel

                  Comment


                  • #10
                    It still won't run via CRON...

                    Comment


                    • #11
                      The next thing I'd check would be the cron logs, located in /var/log/cron

                      It's hard to debug further without access to the server, if you e-mail us at support@interworx.info we'll figure out why the script doesn't seem to be running.

                      Paul
                      Paul Oehler
                      InterWorx-CP | http://interworx.com
                      InterWorx Control Panel

                      Comment


                      • #12
                        Thanks for your offer Paul, however I find I learn better when I am not being babysitted too much :)

                        Comment


                        • #13
                          I understand, I just wanted to put the offer on the table.

                          Paul
                          Paul Oehler
                          InterWorx-CP | http://interworx.com
                          InterWorx Control Panel

                          Comment


                          • #14
                            I understand and appreciate your offer.

                            Anyways after having checked logs again for two days, I can see that the script ran successfully once a day at 1AM, instead of every hour with the following settings: 0, 1, *, *, *

                            So instead of me keep guessing, I would appreciate if you would post instructions here, on how to use CRON, via both interfaces.

                            Thanks

                            Comment


                            • #15
                              To make cron run a script every hour on the hour, the advanced interface should be filled out in the following order:

                              0 * * * *

                              This translates as: On the zeroth minute, of every hour, of every day of the month, on every month, on every day of the week, run this command.

                              This is a long winded way of saying "run this command every hour on the hour"

                              If you had wanted it to run the command at 25 minutes into each hour, you'd say:
                              25 * * * *
                              long winded: On the twenty-fifth minute, of every hour, of every day of the month, on every month, on every day of the week, run this command.

                              The example you used: 0 1 * * *
                              Translates long winded was: On the zeroth minute of the 1st hour (1am) of every day of hte month, on every month, on every day of the week, run this command.

                              Paul
                              Paul Oehler
                              InterWorx-CP | http://interworx.com
                              InterWorx Control Panel

                              Comment

                              Working...
                              X