Announcement

Collapse
No announcement yet.

Reliability of cron jobs?

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

    Reliability of cron jobs?

    Hi folks -- one of my clients just asked about this, and I don't know the answer.

    Suppose a cron job is scheduled to run at 2AM, but the server happens to be down at that time because of an outage, maintenance, etc. Will cron run the job as soon as the server comes back up? Or are we out of luck until the next scheduled time?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    Re: Reliability of cron jobs?

    Nope - only 'for sure' will be it will have to hit that time again to be triggered. Every server is kinda unique so some depends on the server config.

    Comment


      #3
      Re: Reliability of cron jobs?

      You can make it run at reboot just in case, unless rerunning the job creates other issues (@reboot with crontab):

      http://www.cyberciti.biz/faq/linux-e...system-reboot/

      Or look at anacron.
      Last edited by nottheusual1; 04-04-13, 12:02 PM.

      Comment


        #4
        Re: Reliability of cron jobs?

        Or get a server where the chance of being down at 2:00 AM is between .000001% and .00001% <g>.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Re: Reliability of cron jobs?

          2AM - Would that be the time they do maintenance on the servers and maybe reboot? ;-)
          Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
          Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
          Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
          Facebook http://www.facebook.com/EmporiumPlus
          Twitter http://twitter.com/emporiumplus

          Comment


            #6
            Re: Reliability of cron jobs?

            Bill, true, but from my experience, server techs know that a CRON will execute at 2:00 am...and therefore schedule maintenance for 2:05 am...that being said, its probably a good practice for CRONs to issue an email when they finish...and have a manual over ride just in case.
            Last edited by Bruce - PhosphorMedia; 04-04-13, 05:18 PM.
            Bruce Golub
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment


              #7
              Re: Reliability of cron jobs?

              I've written scripts that utilize multiple servers for redundancy.

              Basically, if I'm running a job on a server which needs to excecute everyday, then I would have it execute, and call out to a different server to say it executed.

              If the other server didn't get the "okay", I would get a text-message, letting me know that something was up.

              Also, other methods of control are to have a small log file or database, measuring the last run time of the job (put the updating part in your script), and to set up another job, at a later time, to run the job if it hasn't run yet.
              PCINET, LLC

              Miva Merchant Design, Development, Integration & Support
              We built the most Miva Merchant stores!
              Miva shopping cart design & integration service and our Portfolio!

              e-mail: [email protected]
              web: www.pcinet.com

              "We who cut mere stones must always be envisioning cathedrals."
              Quarry Worker's Creed

              Comment


                #8
                Re: Reliability of cron jobs?

                Actually, I suspect that a lot of hosters do maintenance late at night, when it's less likely to disturb their users ... except for night owls like me :^) . When I'm working on a live store, I prefer to do it late at night. I sometimes find that a store is down, so I email the client; but the store's always fine by the time they get the email the next morning.

                Thanks, everybody, for the suggestions. I may just set up the cron job to run twice a day. In this case, there's no damage caused by running it more often than needed; and the processing overhead is negligible.
                Last edited by Kent Multer; 04-05-13, 08:17 AM.
                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment


                  #9
                  Re: Reliability of cron jobs?

                  I've used a database to manage cron tasks. You set up a cron job to run on the server every X minutes (5-15), and the cron just looks at your database table to see if any tasks need to be run (set up using a timestamp for the "next run"). If any times are in the past (<= NOW()), then you run those tasks. If a cron is missed for any reason, next time around it will be run. I use this for applications that will need multiple crons, but I want an easy way to mange them. Also gives me a lot of other freedoms like allowing me to run jobs by hand without digging in to the command line, or pausing jobs during a maintenance window, etc.).

                  Comment


                    #10
                    Re: Reliability of cron jobs?

                    Hey Brandon, that's a great idea. Have you done this in Miva Script, or are you using other languages & apps?
                    Kent Multer
                    Magic Metal Productions
                    http://TheMagicM.com
                    * Web developer/designer
                    * E-commerce and Miva
                    * Author, The Official Miva Web Scripting Book -- available on-line:
                    http://www.amazon.com/exec/obidos/IS...icmetalproducA

                    Comment


                      #11
                      Re: Reliability of cron jobs?

                      Unfortunately I have only written it in PHP, but the logic isn't overly complex.

                      Comment


                        #12
                        Re: Reliability of cron jobs?

                        Originally posted by Brandon MUS View Post
                        I've used a database to manage cron tasks. You set up a cron job to run on the server every X minutes (5-15), and the cron just looks at your database table to see if any tasks need to be run (set up using a timestamp for the "next run"). If any times are in the past (<= NOW()), then you run those tasks. If a cron is missed for any reason, next time around it will be run. I use this for applications that will need multiple crons, but I want an easy way to mange them. Also gives me a lot of other freedoms like allowing me to run jobs by hand without digging in to the command line, or pausing jobs during a maintenance window, etc.).
                        I've done something just one step below that. It doesn't use the system cron, but works in a small frame on the admin panel. So when I know I'm going to be spending time in the admin, I can turn on "chores". Every 15 min javascript refreshes the pane and sees if there is anything to run. Each chore has a time schedule (only run every x hours), or can be marked "manual only".

                        Any chore can be run manually from the admin, or called externally via a secret key. That way I don't even need to be logged in; just use a specially crafted URI for it to run. Tables keep track of when last run, time took, success or failure, etc.

                        Just moved servers so I'm going to see if I set the whole thing up as a system cron so that things can be run more consistent.

                        Comment

                        Working...
                        X