How to schedule script without cron?

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

    How to schedule script without cron?

    Is there a way to get my script to run on regularly scheduled intervals
    without using cron? My hosting provider sucks... cannot use cron... I was
    thinking perhaps I could create a file every hour in a certain directory and
    then fire the script when the file count reaches a certain number, and then
    clear out the directory... or something like that. Any suggestions?

    Thanks in advance.


  • oeb -=- bleh bleh bleh

    #2
    Re: How to schedule script without cron?


    "deko" <nospam@hotmail .com> wrote in message
    news:gzaJc.1030 7$kU.2006@newss vr25.news.prodi gy.com...[color=blue]
    > Is there a way to get my script to run on regularly scheduled intervals
    > without using cron? My hosting provider sucks... cannot use cron... I[/color]
    was[color=blue]
    > thinking perhaps I could create a file every hour in a certain directory[/color]
    and[color=blue]
    > then fire the script when the file count reaches a certain number, and[/color]
    then[color=blue]
    > clear out the directory... or something like that. Any suggestions?
    >
    > Thanks in advance.
    >
    >[/color]

    You would need cron to create the file every hour unfortunately.

    Maybe if one of your friends has a linux box you could get him to set a cron
    job that point lynx at the script every so often, or else maybe leave a
    browser window open on your machine with a window set to refresh every so
    often (with meta refresh or whatever)


    Comment

    • Edward Alfert

      #3
      Re: How to schedule script without cron?

      "deko" <nospam@hotmail .com> wrote in
      news:gzaJc.1030 7$kU.2006@newss vr25.news.prodi gy.com:
      [color=blue]
      > Is there a way to get my script to run on regularly scheduled
      > intervals without using cron? My hosting provider sucks... cannot use
      > cron... I was thinking perhaps I could create a file every hour in a
      > certain directory and then fire the script when the file count reaches
      > a certain number, and then clear out the directory... or something
      > like that. Any suggestions?
      >
      > Thanks in advance.
      >[/color]

      on your most visited webpage, use some server side code that checks the
      time and if it falls withing your interval range, then run some code.


      --
      Edward Alfert

      Multiple Domain Hosting and Reseller Hosting Plans
      Coupon Code (Recurring $5/month Discount): newsgroup

      Comment

      • deko

        #4
        Re: How to schedule script without cron?

        > You would need cron to create the file every hour unfortunately.

        yeah, I suppose that just begs the question.
        [color=blue]
        > Maybe if one of your friends has a linux box you could get him to set a[/color]
        cron[color=blue]
        > job that point lynx at the script every so often, or else maybe leave a
        > browser window open on your machine with a window set to refresh every so
        > often (with meta refresh or whatever)[/color]

        I have a few linux boxes. So I set up a cron to visit my hosted site? Not
        sure what you mean...


        Comment

        • deko

          #5
          Re: How to schedule script without cron?

          > on your most visited webpage, use some server side code that checks the[color=blue]
          > time and if it falls withing your interval range, then run some code.[/color]

          That sounds interesting. The key is keeping the schedule.

          What I want to do is keep a count of page hits in a 24-hour period, 30-day
          period, and 365-day period. I can assume there will always be at least one
          hit in a 24-hour period.


          Comment

          • Colin McKinnon

            #6
            Re: How to schedule script without cron?

            deko wrote:
            [color=blue]
            > Is there a way to get my script to run on regularly scheduled intervals
            > without using cron? My hosting provider sucks... cannot use cron... I
            > was thinking perhaps I could create a file every hour in a certain
            > directory and then fire the script when the file count reaches a certain
            > number, and then
            > clear out the directory... or something like that. Any suggestions?
            >
            > Thanks in advance.[/color]

            Short answer:

            user@host:~> nohup bash -c '
            while true ; do
            echo run your prog here
            sleep 3600
            done'

            ((((then ctrl-Z))))))
            user@host:~> bg
            user@host:~> exit
            ---------------------------
            better answer:

            read http://www.icon.co.za/~psheer/rute-home.html

            C.


            Comment

            • Michael Austin

              #7
              Re: How to schedule script without cron?

              deko wrote:
              [color=blue]
              > Is there a way to get my script to run on regularly scheduled intervals
              > without using cron? My hosting provider sucks... cannot use cron... I was
              > thinking perhaps I could create a file every hour in a certain directory and
              > then fire the script when the file count reaches a certain number, and then
              > clear out the directory... or something like that. Any suggestions?
              >
              > Thanks in advance.
              >
              >[/color]

              create a "master" process, execute it in the background
              $ ./timer &

              that is in a loop:

              loop
              if nextinterval do something
              wait until nextintervaltim e
              goto loop

              unless you are able to have access to the system level, you are out of luck.
              Any process not assoiciated with the server itself, would probably be detecteced
              and killed. Do yourself a favor, spend a few extra bucks, get DSL or Cable at a
              level that will allow you to run your own server (and use a hardware firewall).
              This can be done using DynamicDNS (static IP not necessary). You will not be
              able to use outbound SMTP because your IP address does not backtranslate, but
              that is no big deal. I use DDNS for inbound POP SMTP and my ISP for outbound.
              If your ISP has a history of lots of downtime during the day, then you may need
              to look for something more stable.

              If they reboot the system for maintenance or whatever, you will have to restart
              your script. Use a box that you have control over... Trying to use ISP
              "freebies" is really bad idea. Bottom line: if it is that important, get your
              own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box on the
              net using DDNS (zoneedit.com). .. All can do {L|V}AMP, but they also do a lot more :)

              --
              Michael Austin.
              Consultant - Available.
              Donations welcomed. Http://www.firstdbasource.com/donations.html
              :)

              Comment

              • oeb -=- bleh bleh bleh

                #8
                Re: How to schedule script without cron?


                "deko" <nospam@hotmail .com> wrote in message
                news:UJaJc.1031 1$qT.8340@newss vr25.news.prodi gy.com...[color=blue][color=green]
                > > You would need cron to create the file every hour unfortunately.[/color]
                >
                > yeah, I suppose that just begs the question.
                >[color=green]
                > > Maybe if one of your friends has a linux box you could get him to set a[/color]
                > cron[color=green]
                > > job that point lynx at the script every so often, or else maybe leave a
                > > browser window open on your machine with a window set to refresh every[/color][/color]
                so[color=blue][color=green]
                > > often (with meta refresh or whatever)[/color]
                >
                > I have a few linux boxes. So I set up a cron to visit my hosted site?[/color]
                Not[color=blue]
                > sure what you mean...
                >
                >[/color]

                Right, Lets say your hosted site (domain.com) has a phpscript in /php/
                called dorun.php that needs to be run every hour, every day add the
                following line to your crontab

                5 * * * 0-6 lynx http://www.domain.com/php/dorun.php

                (I think that is correct, it's been a while since I have used cron)


                Comment

                • deko

                  #9
                  Re: How to schedule script without cron?

                  > on your most visited webpage, use some server side code that checks the[color=blue]
                  > time and if it falls withing your interval range, then run some code.[/color]

                  this is what the log looks like:

                  Jul 13 2004 06:30 pm|68.110.65.24 1|Windows 95|MSIE 5|pacbell.net
                  Jul 13 2004 06:32 pm|68.127.69.10 1|Windows 95|MSIE 5|pacbell.net
                  Jul 13 2004 06:34 pm|203.12.69.23 1|Windows 95|MSIE 5|pacbell.net
                  Jul 13 2004 06:36 pm|64.122.69.14 1|Windows 95|MSIE 5|pacbell.net
                  Jul 13 2004 06:38 pm|68.110.69.26 |Windows 95|MSIE 5|pacbell.net

                  so if I can somehow analyze the date column...

                  if the bottom visit is less than [time() - 3600 * 24] then
                  move to the next line
                  else
                  run script

                  does this sound about right?


                  Comment

                  • Edward Alfert

                    #10
                    Re: How to schedule script without cron?

                    "deko" <nospam@hotmail .com> wrote in
                    news:VNaJc.1031 3$dX.4722@newss vr25.news.prodi gy.com:
                    [color=blue][color=green]
                    >> on your most visited webpage, use some server side code that checks
                    >> the time and if it falls withing your interval range, then run some
                    >> code.[/color]
                    >
                    > That sounds interesting. The key is keeping the schedule.
                    >
                    > What I want to do is keep a count of page hits in a 24-hour period,
                    > 30-day period, and 365-day period. I can assume there will always be
                    > at least one hit in a 24-hour period.
                    >[/color]

                    On every page load write the current date (not time) to a text file and
                    compare it to the previous line. If the date has changed, then count the
                    number of lines in the file (minus 1) and that is the number of hits the
                    previous day. Write this number to a different file including yesterday's
                    date and count.


                    --
                    Edward Alfert

                    Multiple Domain Hosting and Reseller Hosting Plans
                    Coupon Code (Recurring $5/month Discount): newsgroup

                    Comment

                    • Edward Alfert

                      #11
                      Re: How to schedule script without cron?

                      "deko" <nospam@hotmail .com> wrote in news:uZaJc.1031 6$8Y.3454
                      @newssvr25.news .prodigy.com:
                      [color=blue][color=green]
                      >> on your most visited webpage, use some server side code that checks the
                      >> time and if it falls withing your interval range, then run some code.[/color]
                      >
                      > this is what the log looks like:
                      >
                      > Jul 13 2004 06:30 pm|68.110.65.24 1|Windows 95|MSIE 5|pacbell.net
                      > Jul 13 2004 06:32 pm|68.127.69.10 1|Windows 95|MSIE 5|pacbell.net
                      > Jul 13 2004 06:34 pm|203.12.69.23 1|Windows 95|MSIE 5|pacbell.net
                      > Jul 13 2004 06:36 pm|64.122.69.14 1|Windows 95|MSIE 5|pacbell.net
                      > Jul 13 2004 06:38 pm|68.110.69.26 |Windows 95|MSIE 5|pacbell.net
                      >
                      > so if I can somehow analyze the date column...
                      >
                      > if the bottom visit is less than [time() - 3600 * 24] then
                      > move to the next line
                      > else
                      > run script
                      >
                      > does this sound about right?
                      >[/color]

                      Doesn't your host provide analog, webalizer, awstats, or any of the other
                      free log analysys programs?

                      If not, does your hosting provide php and mysql?

                      Just log every visit to a mysql database and whenever you want to know
                      anything about your traffic pattern, query the database.

                      Select count(date) from visitors where date = dateyouwhattokn ow;

                      You can create whatever sql statement you want. This is the way I would do
                      it.

                      --
                      Edward Alfert

                      Multiple Domain Hosting and Reseller Hosting Plans
                      Coupon Code (Recurring $5/month Discount): newsgroup

                      Comment

                      • deko

                        #12
                        Re: How to schedule script without cron?

                        > create a "master" process, execute it in the background[color=blue]
                        > $ ./timer &
                        >
                        > that is in a loop:
                        >
                        > loop
                        > if nextinterval do something
                        > wait until nextintervaltim e
                        > goto loop
                        >
                        > unless you are able to have access to the system level, you are out of[/color]
                        luck.[color=blue]
                        > Any process not assoiciated with the server itself, would probably be[/color]
                        detecteced[color=blue]
                        > and killed. Do yourself a favor, spend a few extra bucks, get DSL or[/color]
                        Cable at a[color=blue]
                        > level that will allow you to run your own server (and use a hardware[/color]
                        firewall).[color=blue]
                        > This can be done using DynamicDNS (static IP not necessary). You will[/color]
                        not be[color=blue]
                        > able to use outbound SMTP because your IP address does not backtranslate,[/color]
                        but[color=blue]
                        > that is no big deal. I use DDNS for inbound POP SMTP and my ISP for[/color]
                        outbound.[color=blue]
                        > If your ISP has a history of lots of downtime during the day, then you may[/color]
                        need[color=blue]
                        > to look for something more stable.
                        >
                        > If they reboot the system for maintenance or whatever, you will have to[/color]
                        restart[color=blue]
                        > your script. Use a box that you have control over... Trying to use ISP
                        > "freebies" is really bad idea. Bottom line: if it is that important, get[/color]
                        your[color=blue]
                        > own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box[/color]
                        on the[color=blue]
                        > net using DDNS (zoneedit.com). .. All can do {L|V}AMP, but they also do a[/color]
                        lot more :)

                        I was looking at DDNS a few weeks ago, but decided to go with a hosting
                        provider for portability purposes - that is, if I move, or change hosting
                        providers, my site is still up and email keeps coming. So uptime was
                        important, and also speed...

                        I do not have access to the server at my hosting provider, so, as you say,
                        I'm out of luck in terms of using a process-based schedule.


                        Comment

                        • deko

                          #13
                          Re: How to schedule script without cron?

                          > user@host:~> nohup bash -c '[color=blue]
                          > while true ; do
                          > echo run your prog here
                          > sleep 3600
                          > done'[/color]

                          that is a good suggestion, but I think a file-based solution might be more
                          reliable - for example, what if the server gets rebooted or something.


                          Comment

                          • deko

                            #14
                            Re: How to schedule script without cron?

                            > Right, Lets say your hosted site (domain.com) has a phpscript in /php/[color=blue]
                            > called dorun.php that needs to be run every hour, every day add the
                            > following line to your crontab
                            >
                            > 5 * * * 0-6 lynx http://www.domain.com/php/dorun.php[/color]

                            That sound like it would work, but then, potentially, anyone could kick off
                            my script. Is this correct? Also, forgive my ignorance, but what is lynx?


                            Comment

                            • deko

                              #15
                              Re: How to schedule script without cron?

                              > On every page load write the current date (not time) to a text file and[color=blue]
                              > compare it to the previous line. If the date has changed, then count the
                              > number of lines in the file (minus 1) and that is the number of hits the
                              > previous day. Write this number to a different file including yesterday's
                              > date and count.[/color]

                              I have the counter script already written - but I want to update the figures
                              every three hours and maintain a rolling count. So, every three hours the
                              figures for each interval (24h, 30d, 365d) are updated. This would be easy
                              to do with cron, but alas, cron cannot be used...


                              Comment

                              Working...