crond

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

    #1

    crond

    How do I create a process that will be called periodically to do some task?
    This is not necessarily php but not sure where to ask.

    Essentially I want to create either a php script or app(C++ would be nice)
    to run once a day that will generate a set of images to be used for
    captchas.

    Any ideas or ideas where I can look for more info?

    Thanks,
    Jon


  • Lammi

    #2
    Re: crond

    you mentioned it in the subject of your post - use cron.



    it's possible to call a php script via cron directly or you call a
    small shellscript, that open the php, f. e.

    #!/bin/sh

    # execute php script
    # -q =quiet, suppress the php-header
    php -q /home/mysql/script.php

    Comment

    • shimmyshack

      #3
      Re: crond

      On Jun 5, 7:21 am, Lammi <Lorenz.Lammers d...@gmail.comw rote:
      you mentioned it in the subject of your post - use cron.
      >

      >
      it's possible to call a php script via cron directly or you call a
      small shellscript, that open the php, f. e.
      >
      #!/bin/sh
      >
      # execute php script
      # -q =quiet, suppress the php-header
      php -q /home/mysql/script.php
      if you can use cron cos you are on windows, use cronw instead. You can
      also register your script as a service and start that every day (the
      service could self-stop after its work is done) then you could use a
      line such as
      "service name" start
      in cron
      I dont see a point to registering as a service, but I mention it just
      for fun!

      Comment

      • Jerry Stuckle

        #4
        Re: crond

        shimmyshack wrote:
        On Jun 5, 7:21 am, Lammi <Lorenz.Lammers d...@gmail.comw rote:
        >you mentioned it in the subject of your post - use cron.
        >>
        >http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
        >>
        >it's possible to call a php script via cron directly or you call a
        >small shellscript, that open the php, f. e.
        >>
        >#!/bin/sh
        >>
        ># execute php script
        ># -q =quiet, suppress the php-header
        >php -q /home/mysql/script.php
        >
        if you can use cron cos you are on windows, use cronw instead. You can
        also register your script as a service and start that every day (the
        service could self-stop after its work is done) then you could use a
        line such as
        "service name" start
        in cron
        I dont see a point to registering as a service, but I mention it just
        for fun!
        >
        Or easier yet - just set up a scheduled task in the control panel.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Jon Slaughter

          #5
          Re: crond


          "shimmyshac k" <matt.farey@gma il.comwrote in message
          news:1181034186 .010284.213020@ p77g2000hsh.goo glegroups.com.. .
          On Jun 5, 7:21 am, Lammi <Lorenz.Lammers d...@gmail.comw rote:
          >you mentioned it in the subject of your post - use cron.
          >>
          >http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
          >>
          >it's possible to call a php script via cron directly or you call a
          >small shellscript, that open the php, f. e.
          >>
          >#!/bin/sh
          >>
          ># execute php script
          ># -q =quiet, suppress the php-header
          >php -q /home/mysql/script.php
          >
          if you can use cron cos you are on windows, use cronw instead. You can
          also register your script as a service and start that every day (the
          service could self-stop after its work is done) then you could use a
          line such as
          "service name" start
          in cron
          I dont see a point to registering as a service, but I mention it just
          for fun!
          >
          Actually guys, I have no idea how to run a script or anything on the web
          host's server but I assume they have this ability? (to schedule maintenance)

          I think its a linux platform so I image they have crond or something like
          that. There web site forum was down last time I checked so I haven't found
          out whats really going on.

          Thanks,
          Jon


          Comment

          • Jerry Stuckle

            #6
            Re: crond

            Jon Slaughter wrote:
            "shimmyshac k" <matt.farey@gma il.comwrote in message
            news:1181034186 .010284.213020@ p77g2000hsh.goo glegroups.com.. .
            >On Jun 5, 7:21 am, Lammi <Lorenz.Lammers d...@gmail.comw rote:
            >>you mentioned it in the subject of your post - use cron.
            >>>
            >>http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
            >>>
            >>it's possible to call a php script via cron directly or you call a
            >>small shellscript, that open the php, f. e.
            >>>
            >>#!/bin/sh
            >>>
            >># execute php script
            >># -q =quiet, suppress the php-header
            >>php -q /home/mysql/script.php
            >if you can use cron cos you are on windows, use cronw instead. You can
            >also register your script as a service and start that every day (the
            >service could self-stop after its work is done) then you could use a
            >line such as
            >"service name" start
            >in cron
            >I dont see a point to registering as a service, but I mention it just
            >for fun!
            >>
            >
            Actually guys, I have no idea how to run a script or anything on the web
            host's server but I assume they have this ability? (to schedule maintenance)
            >
            I think its a linux platform so I image they have crond or something like
            that. There web site forum was down last time I checked so I haven't found
            out whats really going on.
            >
            Thanks,
            Jon
            >
            >
            Jon,

            You may or may not have the ability. It depends on the permissions the
            host gave you. Some allow cron jobs, some don't.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Jon Slaughter

              #7
              Re: crond

              >
              You may or may not have the ability. It depends on the permissions the
              host gave you. Some allow cron jobs, some don't.
              Now is that really the only way to schedule stuff in a linux enviroment? I
              mentione dthe crond int eh subject cause thats all I know about.

              What I'm trying to get at, is it going to be impossible to schedule stuff if
              the host doesn't have it setup to do that? Obviously it can be impossible
              but here I mean in general for most web hosts is it a common thing to allow
              or deny?

              Also is there any way to check for schelduling abilities? I have no shell in
              the web host I think... just ftp and http.

              oh, wait, I think I do have schelduling abilities... in the control panel
              stuff for the site. I'll have to go check and see as I remember seeing that.

              Thanks,
              Jon


              Comment

              • Jon Slaughter

                #8
                Re: crond

                oh, wait, I think I do have schelduling abilities... in the control panel
                stuff for the site. I'll have to go check and see as I remember seeing
                that.
                >
                Yep, I guess they do. Has a way to add cron jobs and just have to give it
                the script name.

                I assume this is bash stuff? (I haven't done any unix scripting in a very
                long time and very little but I assume the other posts give the script that
                will work here). I just remember there being several types

                Ultimately though I'd like to create a C++ app that will generate the
                captchas since it will probably be optimized. I'm not sure how the web hosts
                deal with time sharing but I don't want to take to much time. Ultimately I'd
                like to generate the captchas in real time when they are needed and apply
                random transformations to them instead of pre generating but I think this
                might be to slow. (not sure how long it will take to generate one)

                I guess I can do some tests and find out though after I get the thing
                working.

                Thanks,
                Jon


                Comment

                • Rik

                  #9
                  Re: crond

                  On Tue, 05 Jun 2007 18:14:15 +0200, Jon Slaughter
                  <Jon_Slaughter@ Hotmail.comwrot e:
                  >>
                  >You may or may not have the ability. It depends on the permissions the
                  >host gave you. Some allow cron jobs, some don't.
                  >
                  Now is that really the only way to schedule stuff in a linux enviroment?
                  I
                  mentione dthe crond int eh subject cause thats all I know about.
                  >
                  What I'm trying to get at, is it going to be impossible to schedule
                  stuff if
                  the host doesn't have it setup to do that? Obviously it can be impossible
                  but here I mean in general for most web hosts is it a common thing to
                  allow
                  or deny?
                  >
                  Also is there any way to check for schelduling abilities? I have no
                  shell in
                  the web host I think... just ftp and http.
                  >
                  oh, wait, I think I do have schelduling abilities... in the control panel
                  stuff for the site. I'll have to go check and see as I remember seeing
                  that.
                  That's where most hosters that allow it put it indeed. Gives them somewhat
                  more control then allowing it by shell.

                  If they don't offer it, you could always put up a page that does the work,
                  and call that from a computer that does have scheduling enabled. (Possibly
                  with some safety checks.)

                  --
                  Rik Wasmus

                  Comment

                  • Toby A Inkster

                    #10
                    Re: crond

                    Jon Slaughter wrote:
                    I assume this is bash stuff? (I haven't done any unix scripting in a very
                    long time and very little but I assume the other posts give the script that
                    will work here). I just remember there being several types
                    Cron doesn't specifically require bash scripting.

                    Cron can be used to launch any executable file at a frequency of up to
                    once per minute. (Or as infrequent as once every 28 years[1] if need be,
                    but that seems a bit excessive -- if something needs scheduling that
                    infrequently, you're better off running it manually.)

                    These executables could be bash scripts, tcsh scripts, Perl scripts,
                    compiled C code, or raw machine code written in a hex editor if you
                    like -- anything that you could run from the command line can run from
                    cron.

                    That said, most people do seem to use either Perl or some form of shell
                    scripting for cron jobs.

                    ____
                    1. Cron users may not believe this, as cron tabs only allow you to specify
                    minutes, hours, days and months, so it's not clear how to schedule a job
                    to happen once every 28 years. Technically, you can't, but you can
                    approximate it by scheduling the job to happen on Sunday 29th February, a
                    date which only occurs (on average) every 28 years, because of leap years
                    and the fact that there isn't an integer number of weeks in each year.
                    Under normal usage, the longest time between cron jobs is 1 year.

                    --
                    Toby A Inkster BSc (Hons) ARCS
                    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                    [OS: Linux 2.6.12-12mdksmp, up 102 days, 1:16.]

                    URLs in demiblog

                    Comment

                    • Toby A Inkster

                      #11
                      Re: crond

                      Jon Slaughter wrote:
                      Now is that really the only way to schedule stuff in a linux enviroment?
                      Cron? No -- there is also "at", but that's more suited towards scheduling a
                      one-off event in the future.

                      Or you could write a system service that sleeps for X seconds, wakes up,
                      does its job and then sleeps again.

                      --
                      Toby A Inkster BSc (Hons) ARCS
                      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                      [OS: Linux 2.6.12-12mdksmp, up 102 days, 1:25.]

                      URLs in demiblog

                      Comment

                      • shimmyshack

                        #12
                        Re: crond

                        On Jun 5, 6:43 pm, Toby A Inkster <usenet200...@t obyinkster.co.u k>
                        wrote:
                        Jon Slaughter wrote:
                        Now is that really the only way to schedule stuff in a linux enviroment?
                        >
                        Cron? No -- there is also "at", but that's more suited towards scheduling a
                        one-off event in the future.
                        >
                        Or you could write a system service that sleeps for X seconds, wakes up,
                        does its job and then sleeps again.
                        >
                        --
                        Toby A Inkster BSc (Hons) ARCS
                        [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                        [OS: Linux 2.6.12-12mdksmp, up 102 days, 1:25.]
                        >
                        URLs in demiblog
                        http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
                        you could also write a php script that is behind some protection,
                        which a cron on a machine you do have access to executes.
                        http://server.com/doit/job63.php?log=secure_email or whatever.

                        Comment

                        • Jon Slaughter

                          #13
                          Re: crond


                          "Toby A Inkster" <usenet200705@t obyinkster.co.u kwrote in message
                          news:unjgj4-h76.ln1@ophelia .g5n.co.uk...
                          Jon Slaughter wrote:
                          >
                          >I assume this is bash stuff? (I haven't done any unix scripting in a very
                          >long time and very little but I assume the other posts give the script
                          >that
                          >will work here). I just remember there being several types
                          >
                          Cron doesn't specifically require bash scripting.
                          >
                          Cron can be used to launch any executable file at a frequency of up to
                          once per minute. (Or as infrequent as once every 28 years[1] if need be,
                          but that seems a bit excessive -- if something needs scheduling that
                          infrequently, you're better off running it manually.)
                          >
                          These executables could be bash scripts, tcsh scripts, Perl scripts,
                          compiled C code, or raw machine code written in a hex editor if you
                          like -- anything that you could run from the command line can run from
                          cron.
                          >
                          That said, most people do seem to use either Perl or some form of shell
                          scripting for cron jobs.
                          >
                          Thanks... I'll try to do some more research on it and see what I come up
                          with... on what to do. I like the idea of using php but I think it won't be
                          fast enough so I'll look into doing it in C++ and then figure out how to run
                          it(since I'm on a windows machine I'll have to compile it for linux somehow)

                          Jon


                          Comment

                          • shimmyshack

                            #14
                            Re: crond

                            On Jun 5, 9:34 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
                            "Toby A Inkster" <usenet200...@t obyinkster.co.u kwrote in messagenews:unj gj4-h76.ln1@ophelia .g5n.co.uk...
                            >
                            >
                            >
                            Jon Slaughter wrote:
                            >
                            I assume this is bash stuff? (I haven't done any unix scripting in a very
                            long time and very little but I assume the other posts give the script
                            that
                            will work here). I just remember there being several types
                            >
                            Cron doesn't specifically require bash scripting.
                            >
                            Cron can be used to launch any executable file at a frequency of up to
                            once per minute. (Or as infrequent as once every 28 years[1] if need be,
                            but that seems a bit excessive -- if something needs scheduling that
                            infrequently, you're better off running it manually.)
                            >
                            These executables could be bash scripts, tcsh scripts, Perl scripts,
                            compiled C code, or raw machine code written in a hex editor if you
                            like -- anything that you could run from the command line can run from
                            cron.
                            >
                            That said, most people do seem to use either Perl or some form of shell
                            scripting for cron jobs.
                            >
                            Thanks... I'll try to do some more research on it and see what I come up
                            with... on what to do. I like the idea of using php but I think it won't be
                            fast enough so I'll look into doing it in C++ and then figure out how to run
                            it(since I'm on a windows machine I'll have to compile it for linux somehow)
                            >
                            Jon
                            php offloads some of its work onto c libraries anyway, so unless you
                            have a specific task in mind that php does not offload, you might not
                            find too much diff in perf, my $0.02

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: crond

                              Jon Slaughter wrote:
                              >You may or may not have the ability. It depends on the permissions the
                              >host gave you. Some allow cron jobs, some don't.
                              >
                              Now is that really the only way to schedule stuff in a linux enviroment? I
                              mentione dthe crond int eh subject cause thats all I know about.
                              >
                              What I'm trying to get at, is it going to be impossible to schedule stuff if
                              the host doesn't have it setup to do that? Obviously it can be impossible
                              but here I mean in general for most web hosts is it a common thing to allow
                              or deny?
                              >
                              Also is there any way to check for schelduling abilities? I have no shell in
                              the web host I think... just ftp and http.
                              >
                              oh, wait, I think I do have schelduling abilities... in the control panel
                              stuff for the site. I'll have to go check and see as I remember seeing that.
                              >
                              Thanks,
                              Jon
                              >
                              >
                              As I said - it's all up to the host. Some disable it because abuse can
                              affect system performance.

                              And yes, that is the scheduler for Linux. You can probably find some
                              other programs which emulate it, but cron is built into the system and
                              works the best. And if they disabled cron, chances are there is a
                              reason and they would be upset if you tried to bypass it.

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...