Announcement

Collapse
No announcement yet.

creating unique files with cron?

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

    creating unique files with cron?

    Hi folks --

    I'm setting up a custom module for a client that will use a cron job to run the module automatically once a day. The cron command uses the ">path/autorun.html" notation to save the output of the job into a file. I'd like to have the module use a different file name each time. Ideally this would be done by including a date and time in the filename, but that's not absolutely necessary; the files could be consecutively numbered, or even semi-random, as long as they're unique. Is there a way to do that?

    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: creating unique files with cron?

    wouldn't it be just as easy for the module to create its output into a file with whatever file naming schema you want? What would be the advantage or disadvantage to specifying the file at the execution call (i.e., CRON).
    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


      #3
      Re: creating unique files with cron?

      The ">file" notation is used to capture the actual output of the module, the HTML code that would be displayed on the browser screen if we ran the module manually. It'd be kind of a pain to modify the module to stuff all that into a log file. I was hoping there was some kind of Linux shortcut for this.

      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

      Comment


        #4
        Re: creating unique files with cron?

        If I understand, you don't want to modify the module to "create" the filename, you want to capture the modules output and stuff the output it into a time stamped file name.

        If that's correct you could two step it.

        Create a second simple capture program (aka logme.mvc) that calls your module and MvCaptures the output, saving it to your time stamped file.

        Your Cron tasks will call logme.mvc not your module.
        Ray Yates
        "If I have seen further, it is by standing on the shoulders of giants."
        --- Sir Isaac Newton

        Comment


          #5
          Re: creating unique files with cron?

          Use cron to call a shell script which uses curl or wget to call the module with the time parameter added to it?

          Comment


            #6
            Re: creating unique files with cron?

            Those are good ideas, thanks. It also occurred to me, I could create a second cron job that runs a few minutes after the first one, and renames the file.
            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


              #7
              Re: creating unique files with cron?

              Just be careful of timing issues if you use a second script. You don't want to rename your file until the last job is complete so make sure there is a good buffer space between the two.

              Comment

              Working...
              X