How to schedule script without cron?

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

    #16
    Re: How to schedule script without cron?

    > Doesn't your host provide analog, webalizer, awstats, or any of the other[color=blue]
    > free log analysys programs?[/color]

    Yes, but this has a special purpose
    [color=blue]
    > If not, does your hosting provide php and mysql?[/color]

    Yes, but I need a file-based solution





    Comment

    • deko

      #17
      Re: How to schedule script without cron?

      > > Jul 13 2004 06:30 pm|68.110.65.24 1|Windows 95|MSIE 5|pacbell.net[color=blue][color=green]
      > > 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][/color]

      Is there a way to get file modification time in php? Perhaps I could just
      check the mod date of a file with each visit.

      For example, each time the site is visited, write something to a file.
      Then, a separate script checks that file's mod date. If the mod date is 3
      hours old, then run the script. Do you think this would work?


      Comment

      • oeb -=- bleh bleh bleh

        #18
        Re: How to schedule script without cron?


        "deko" <nospam@hotmail .com> wrote in message
        news:E6bJc.1031 9$SY.6448@newss vr25.news.prodi gy.com...[color=blue][color=green]
        > > 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[/color]
        >
        > That sound like it would work, but then, potentially, anyone could kick[/color]
        off[color=blue]
        > my script. Is this correct? Also, forgive my ignorance, but what is[/color]
        lynx?[color=blue]
        >
        >[/color]

        lynx is a text based browser that ships with most linux distros.

        You could always put a clause in the script to only allow you to run it (For
        example must have a certain password, or http authentication. ) but otherwise
        anyone could run it yes.


        Comment

        • Edward Alfert

          #19
          Re: How to schedule script without cron?

          "deko" <nospam@hotmail .com> wrote in
          news:KibJc.1032 4$p_.987@newssv r25.news.prodig y.com:
          [color=blue][color=green][color=darkred]
          >> > 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][/color]
          >
          > Is there a way to get file modification time in php? Perhaps I could
          > just check the mod date of a file with each visit.
          >
          > For example, each time the site is visited, write something to a file.
          > Then, a separate script checks that file's mod date. If the mod date
          > is 3 hours old, then run the script. Do you think this would work?[/color]

          yes... take a look at user comments at



          --
          Edward Alfert

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

          Comment

          • deko

            #20
            Re: How to schedule script without cron?

            > You could always put a clause in the script to only allow you to run it
            (For[color=blue]
            > example must have a certain password, or http authentication. ) but[/color]
            otherwise[color=blue]
            > anyone could run it yes.[/color]

            Perhaps I could check the modification date of a file with php and base my
            scheduling on that. I could use lynx simply to visit the site at 12:00 each
            day, which would create a benchmark file. Then my script checks the mod
            date of that file... woudl this work? How to check the mod date of a file
            with php?

            I would like to know more abotu using lynx and authentication - for example,
            can I automate a login to my bank's online banking page to get my bank
            balance each day? Of course, that site uses encription and probally a bunch
            of other security I don't understand...



            Comment

            • deko

              #21
              Re: How to schedule script without cron?

              > > Is there a way to get file modification time in php? Perhaps I could[color=blue][color=green]
              > > just check the mod date of a file with each visit.
              > >
              > > For example, each time the site is visited, write something to a file.
              > > Then, a separate script checks that file's mod date. If the mod date
              > > is 3 hours old, then run the script. Do you think this would work?[/color]
              >
              > yes... take a look at user comments at
              > http://www.php.net/manual/en/function.fileatime.php[/color]

              I think that's the answer... Thanks!!


              Comment

              • oeb -=- bleh bleh bleh

                #22
                Re: How to schedule script without cron?


                "deko" <nospam@hotmail .com> wrote in message
                news:nxbJc.1032 6$q51.2318@news svr25.news.prod igy.com...[color=blue][color=green]
                > > You could always put a clause in the script to only allow you to run it[/color]
                > (For[color=green]
                > > example must have a certain password, or http authentication. ) but[/color]
                > otherwise[color=green]
                > > anyone could run it yes.[/color]
                >
                > Perhaps I could check the modification date of a file with php and base my
                > scheduling on that. I could use lynx simply to visit the site at 12:00[/color]
                each[color=blue]
                > day, which would create a benchmark file. Then my script checks the mod
                > date of that file... woudl this work? How to check the mod date of a file
                > with php?[/color]



                [color=blue]
                >
                > I would like to know more abotu using lynx and authentication - for[/color]
                example,[color=blue]
                > can I automate a login to my bank's online banking page to get my bank
                > balance each day? Of course, that site uses encription and probally a[/color]
                bunch[color=blue]
                > of other security I don't understand...[/color]

                I don't know about your bank, but mine uses java, activex, javascript and a
                bunch of other crap lynx can not support, so I would not be able to get past
                the login screen.

                HTTP Authentication on the other hand is achieved through .htaccess and
                ..htpasswd (Or it can be done through PHP too)

                A page using HTTP Authentication can be accessed in the following manner.

                http://user:password@domain.com

                Thus allowing it to be easily accessed from a browser launched via cron
                while also giving it some measure of security.


                HTTP AUTHENTICATION IN PHP (This will only work on apache afaik)

                <?php

                if ((!isset($PHP_A UTH_USER) || $PHP_AUTH_USER != "USERNAME") &&
                (!isset($PHP_AU TH_PW) || $PHP_AUTH_PW != "ABERDEEN") ) {
                header("WWW-Authenticate: Basic realm=\"cronexa mple\"");
                Header("HTTP/1.0 401 Unauthorized");
                echo "<html><bod y bgcolor=efefef> ";
                echo "You must have a username and password to access this site.";
                exit;
                }
                else if(($PHP_AUTH_U SER=="USERNAME" ) && ($PHP_AUTH_PW== "PASSWORD") )
                {
                $cookiename = "auth";
                $cookievalue = "ok";
                $cookieexpire = time()+9200;
                $cookiedomain = "";
                setcookie($cook iename, $cookievalue, $cookieexpire, "/", $cookiedomain,
                0);
                }
                ?>

                And you can do your file stuff here.


                Comment

                • Michael Austin

                  #23
                  Re: How to schedule script without cron?

                  deko wrote:
                  [color=blue][color=green]
                  >>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[/color]
                  >
                  > luck.
                  >[color=green]
                  >>Any process not assoiciated with the server itself, would probably be[/color]
                  >
                  > detecteced
                  >[color=green]
                  >>and killed. Do yourself a favor, spend a few extra bucks, get DSL or[/color]
                  >
                  > Cable at a
                  >[color=green]
                  >>level that will allow you to run your own server (and use a hardware[/color]
                  >
                  > firewall).
                  >[color=green]
                  >> This can be done using DynamicDNS (static IP not necessary). You will[/color]
                  >
                  > not be
                  >[color=green]
                  >>able to use outbound SMTP because your IP address does not backtranslate,[/color]
                  >
                  > but
                  >[color=green]
                  >>that is no big deal. I use DDNS for inbound POP SMTP and my ISP for[/color]
                  >
                  > outbound.
                  >[color=green]
                  >>If your ISP has a history of lots of downtime during the day, then you may[/color]
                  >
                  > need
                  >[color=green]
                  >>to look for something more stable.
                  >>
                  >>If they reboot the system for maintenance or whatever, you will have to[/color]
                  >
                  > restart
                  >[color=green]
                  >>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=green]
                  >>own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box[/color]
                  >
                  > on the
                  >[color=green]
                  >>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.
                  >
                  >[/color]

                  Unless it takes you more than 48 hours to move and get your new connection set
                  up, that shouldn't be a problem. I used ZoneEdits email "store-and-forward" as
                  a backup mail server. The mail just collected there while I moved from NC to
                  KC. The server was down for about 7-10 days - no email was missed... took a
                  while to read through them...

                  If you change providers you also may have to change registrars for your domain
                  name(some force the change - which is really stupid, but whatever...) When this
                  occurs, it takes 2-3 days for the new information to be propogated. So, using
                  DynDNS and registering the domain name yourself where you have control over the
                  technical information such as primary DNS etc... then it is actually a lot
                  better than trying to play by the minimalist rules of ISP-based hosting. You
                  have to play by their rules and applications.

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

                  Comment

                  • deko

                    #24
                    Re: How to schedule script without cron?

                    > I don't know about your bank, but mine uses java, activex, javascript and
                    a[color=blue]
                    > bunch of other crap lynx can not support, so I would not be able to get[/color]
                    past[color=blue]
                    > the login screen.
                    >
                    > HTTP Authentication on the other hand is achieved through .htaccess and
                    > .htpasswd (Or it can be done through PHP too)
                    >
                    > A page using HTTP Authentication can be accessed in the following manner.
                    >
                    > http://user:password@domain.com
                    >
                    > Thus allowing it to be easily accessed from a browser launched via cron
                    > while also giving it some measure of security.
                    >
                    >
                    > HTTP AUTHENTICATION IN PHP (This will only work on apache afaik)
                    >
                    > <?php
                    >
                    > if ((!isset($PHP_A UTH_USER) || $PHP_AUTH_USER != "USERNAME") &&
                    > (!isset($PHP_AU TH_PW) || $PHP_AUTH_PW != "ABERDEEN") ) {
                    > header("WWW-Authenticate: Basic realm=\"cronexa mple\"");
                    > Header("HTTP/1.0 401 Unauthorized");
                    > echo "<html><bod y bgcolor=efefef> ";
                    > echo "You must have a username and password to access this site.";
                    > exit;
                    > }
                    > else if(($PHP_AUTH_U SER=="USERNAME" ) && ($PHP_AUTH_PW== "PASSWORD") )
                    > {
                    > $cookiename = "auth";
                    > $cookievalue = "ok";
                    > $cookieexpire = time()+9200;
                    > $cookiedomain = "";
                    > setcookie($cook iename, $cookievalue, $cookieexpire, "/", $cookiedomain,
                    > 0);
                    > }
                    > ?>
                    >
                    > And you can do your file stuff here.
                    >[/color]


                    cool... I will play around with this. Thanks.


                    Comment

                    • deko

                      #25
                      Re: How to schedule script without cron?

                      > Unless it takes you more than 48 hours to move and get your new connection
                      set[color=blue]
                      > up, that shouldn't be a problem. I used ZoneEdits email[/color]
                      "store-and-forward" as[color=blue]
                      > a backup mail server. The mail just collected there while I moved from NC[/color]
                      to[color=blue]
                      > KC. The server was down for about 7-10 days - no email was missed... took[/color]
                      a[color=blue]
                      > while to read through them...
                      >
                      > If you change providers you also may have to change registrars for your[/color]
                      domain[color=blue]
                      > name(some force the change - which is really stupid, but whatever...) When[/color]
                      this[color=blue]
                      > occurs, it takes 2-3 days for the new information to be propogated. So,[/color]
                      using[color=blue]
                      > DynDNS and registering the domain name yourself where you have control[/color]
                      over the[color=blue]
                      > technical information such as primary DNS etc... then it is actually a lot
                      > better than trying to play by the minimalist rules of ISP-based hosting.[/color]
                      You[color=blue]
                      > have to play by their rules and applications.[/color]

                      I've already purchased a year of hosting, so I'll be using that for now -
                      but would like to set up another site with DDNS... I've got enough linux
                      boxes in teh garage... might as well put them onthe air... How do I get
                      started? Can you point me to a site that shows me how?


                      Comment

                      • Tim Van Wassenhove

                        #26
                        Re: How to schedule script without cron?

                        In article <gzaJc.10307$kU .2006@newssvr25 .news.prodigy.c om>, 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?[/color]

                        You could look in the archives of this group. Question has been asked
                        many times before.

                        --
                        Tim Van Wassenhove <http://home.mysth.be/~timvw>

                        Comment

                        • Pjotr Wedersteers

                          #27
                          Re: How to schedule script without cron?

                          deko wrote:[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]

                          Would it not be easier to use the time () function ? (returns seconds passed
                          since 1-1-1970)
                          Simply write it to a file the first time.
                          Every next run compare time () to the stored version. If the difference in
                          seconds becomes larger than your desired interval, do your stuff and rewrite
                          the file with the new timestamp.
                          Pjotr


                          Comment

                          • Michael Austin

                            #28
                            Re: How to schedule script without cron?

                            deko wrote:
                            [color=blue][color=green]
                            >>Unless it takes you more than 48 hours to move and get your new connection[/color]
                            >
                            > set
                            >[color=green]
                            >>up, that shouldn't be a problem. I used ZoneEdits email[/color]
                            >
                            > "store-and-forward" as
                            >[color=green]
                            >>a backup mail server. The mail just collected there while I moved from NC[/color]
                            >
                            > to
                            >[color=green]
                            >>KC. The server was down for about 7-10 days - no email was missed... took[/color]
                            >
                            > a
                            >[color=green]
                            >>while to read through them...
                            >>
                            >>If you change providers you also may have to change registrars for your[/color]
                            >
                            > domain
                            >[color=green]
                            >>name(some force the change - which is really stupid, but whatever...) When[/color]
                            >
                            > this
                            >[color=green]
                            >>occurs, it takes 2-3 days for the new information to be propogated. So,[/color]
                            >
                            > using
                            >[color=green]
                            >>DynDNS and registering the domain name yourself where you have control[/color]
                            >
                            > over the
                            >[color=green]
                            >>technical information such as primary DNS etc... then it is actually a lot
                            >>better than trying to play by the minimalist rules of ISP-based hosting.[/color]
                            >
                            > You
                            >[color=green]
                            >>have to play by their rules and applications.[/color]
                            >
                            >
                            > I've already purchased a year of hosting, so I'll be using that for now -
                            > but would like to set up another site with DDNS... I've got enough linux
                            > boxes in teh garage... might as well put them onthe air... How do I get
                            > started? Can you point me to a site that shows me how?
                            >
                            >[/color]

                            All you need is a router that can support port-forwarding. In fact, there are
                            tons of examples (google for linux broadband router) should get you started.

                            you can start at http://www.firstdbasource.com/ and click on "how do I put
                            openvms on broadband" you will have to make the appropriate technology
                            translations, but shouldn't be that difficult.

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

                            Comment

                            • deko

                              #29
                              Re: How to schedule script without cron?

                              > All you need is a router that can support port-forwarding. In fact, there
                              are[color=blue]
                              > tons of examples (google for linux broadband router) should get you[/color]
                              started.[color=blue]
                              >
                              > you can start at http://www.firstdbasource.com/ and click on "how do I put
                              > openvms on broadband" you will have to make the appropriate technology
                              > translations, but shouldn't be that difficult.[/color]

                              Sounds interesteing - I'll take a look.

                              As for reworking my script to run without cron, I think I've got an idea....

                              Here is what the file looks like that contains a record of site visits:

                              Jul 14 2004 09:30 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089822637
                              Jul 14 2004 09:30 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089822644
                              Jul 14 2004 09:31 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089822679
                              Jul 14 2004 09:31 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089822686
                              Jul 14 2004 09:47 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089823630
                              Jul 14 2004 09:47 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089823638
                              Jul 14 2004 11:09 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089828547
                              Jul 14 2004 11:09 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089828553
                              Jul 14 2004 11:16 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089829014
                              Jul 14 2004 11:16 am|68.122.69.24 1|Windows Server|MSIE
                              6|pacbell.net|1 089829019

                              The last column is time()

                              So, if I can count the number of lines in this file that are within the the
                              intervals in question, I'll have the count for each interval:

                              number of entries > time() - (3600*24) = $hr24
                              number of entries > time() - (3600*24*30) = $d30
                              number of entries > time() - (3600*24*365) = $d365

                              But how do I count lines in a file?



                              Comment

                              • R. Rajesh Jeba Anbiah

                                #30
                                Re: How to schedule script without cron?

                                "deko" <nospam@hotmail .com> wrote in message news:<gzaJc.103 07$kU.2006@news svr25.news.prod igy.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?[/color]

                                1. Fakecron
                                a. using PHP include/require
                                b. using webbug
                                2. 3rd party remote cron <http://hostedcron.com/>

                                --
                                | Just another PHP saint |
                                Email: rrjanbiah-at-Y!com

                                Comment

                                Working...