Thread

  1. Help

    Mohamed ebrahim <mohdebrahim@yahoo.com> — 2001-03-25T06:49:05Z

    Hi,
    
        I am a user postgresql. I want to update a table
    automatically when we reach monthend. i.e i want to
    update some table on 31 of every month automatically
    without any user attention. I want to know how to do
    this. If anyone knows how to do this please mail me. i
    will be ever thankfull to him
    
    Thank you
    
    Ebrahim
    
    __________________________________________________
    Do You Yahoo!?
    Get email at your own domain with Yahoo! Mail. 
    http://personal.mail.yahoo.com/
    
    
  2. Re: Help

    Joe Conway <jconway2@home.com> — 2001-03-25T20:16:33Z

    >     I am a user postgresql. I want to update a table
    > automatically when we reach monthend. i.e i want to
    > update some table on 31 of every month automatically
    > without any user attention. I want to know how to do
    > this. If anyone knows how to do this please mail me. i
    > will be ever thankfull to him
    
    Probably the easiest way to do this is to write a script and run it from
    cron. For example, if your update query is in a file called
    $HOME/bin/monthend.sql:
    
        insert into mymonthendtable(f1, f2, f3)
    values(123,'03/31/2001',12345.67);
    
    your script (call it $HOME/bin/monthend.sh) might look like:
    
        #!/bin/sh
        psql -U postgres mydatabasename < $HOME/bin/monthend.sql
    
    then run (see "man 5 crontab" for more on cron)
        crontab -e
    
    and add an entry like
    
        # run at 2:15 AM on the 30th of every month
        15 2 30 * *     $HOME/bin/monthend.sh
    
    Hope this helps,
    
    Joe
    
    
    
    
  3. Re: Help

    Peter Eisentraut <peter_e@gmx.net> — 2001-03-25T20:21:07Z

    Mohamed ebrahim writes:
    
    >     I am a user postgresql. I want to update a table
    > automatically when we reach monthend. i.e i want to
    > update some table on 31 of every month automatically
    > without any user attention.
    
    Use a cron job.
    
    -- 
    Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/
    
    
    
  4. Re: Help

    Richard Huxton <dev@archonet.com> — 2001-03-25T20:23:22Z

    From: "Mohamed ebrahim" <mohdebrahim@yahoo.com>
    
    > Hi,
    >
    >     I am a user postgresql. I want to update a table
    > automatically when we reach monthend. i.e i want to
    > update some table on 31 of every month automatically
    > without any user attention. I want to know how to do
    > this. If anyone knows how to do this please mail me. i
    > will be ever thankfull to him
    
    I'm presuming that you are on some kind of unix-like system. If so, check
    the "cron" system (man cron, man crontab) - use this to run a script at a
    set time each month - the script can then update your database.
    
    This can be as simple as placing a script into /etc/cron.monthly/ on some
    systems (e.g. Linux Redhat) but in any case is not too complicated.
    
    PS - it is usually easier to do this early on the first day of each month
    (every month has a day 1, not all have a day 31).
    
    - Richard Huxton
    
    
    
  5. Help

    Mohamed ebrahim <mohdebrahim@yahoo.com> — 2001-03-26T07:36:31Z

    Hi, 
    
      Thanks for your valuable information. I tried the
    cron. i typed
       cron -e
    and entereed into the input area. but i don't know how
    to save the cron file. I pressed ctrl+z and came out
    from cron. but i edit the cron file i found nothing on
    it.(i.e using pico filename.) Please tell me some
    description how to save the file in cron and to achive
    this. I will be thankful to you.
    
    Ebrahim
    
    >     I am a user postgresql. I want to update a table
    > automatically when we reach monthend. i.e i want to
    > update some table on 31 of every month automatically
    > without any user attention. I want to know how to do
    > this. If anyone knows how to do this please mail me.
    >i
    > will be ever thankfull to him.
    
    
    
    >Joe wrote:
    >
    >Probably the easiest way to do this is to write a
    >script and run it 
    >from
    >cron. For example, if your update query is in a file
    >called
    >$HOME/bin/monthend.sql:
    >
    >    insert into mymonthendtable(f1, f2, f3)
    >values(123,'03/31/2001',12345.67);
    >
    >your script (call it $HOME/bin/monthend.sh) might
    >look like:
    >
    >    #!/bin/sh
    >    psql -U postgres mydatabasename <
    >$HOME/bin/monthend.sql
    >
    >then run (see "man 5 crontab" for more on cron)
    >    crontab -e
    >
    >and add an entry like
    >
    >    # run at 2:15 AM on the 30th of every month
    >    15 2 30 * *     $HOME/bin/monthend.sh
    >
    >Hope this helps,
    >
    >Joe
    >
    
    __________________________________________________
    Do You Yahoo!?
    Get email at your own domain with Yahoo! Mail. 
    http://personal.mail.yahoo.com/
    
    
  6. Re: Help

    Joe Conway <jconway2@home.com> — 2001-03-26T15:56:54Z

    >   Thanks for your valuable information. I tried the
    > cron. i typed
    >    cron -e
    > and entereed into the input area. but i don't know how
    > to save the cron file. I pressed ctrl+z and came out
    > from cron. but i edit the cron file i found nothing on
    > it.(i.e using pico filename.) Please tell me some
    > description how to save the file in cron and to achive
    > this. I will be thankful to you.
    >
    
    Instead of "ctrl+z", press ":wq" (colon for command mode, w for write, q for
    quit). This assumes that vi is your default editor.
    
    Joe
    
    
    
  7. Re: Help

    selkovjr@mcs.anl.gov — 2001-03-26T19:47:30Z

    > Instead of "ctrl+z", press ":wq" (colon for command mode, w for write, q for
    > quit).
    
    If you are still mystified, "ctrl+z" stops a process running on a
    terminal, so it's likely that your vi is still running idle. Type 'fg'
    on the same terminal to bring it back. For more details on job
    control, see 'info sh' and search for 'jobs'.
    
    > This assumes that vi is your default editor.
    
    Which you can change by setting your EDITOR environment variable.
    
    For example, if your shell is bash,
    
    	export EDITOR="emacs -nw"
    
    will do it.
    
    --Gene
    
    
  8. Re: Help

    Cedar Cox <cedarc@visionforisrael.com> — 2001-03-26T20:38:37Z

    > >   Thanks for your valuable information. I tried the
    > > cron. i typed
    > >    cron -e
    > > and entereed into the input area. but i don't know how
    > > to save the cron file. I pressed ctrl+z and came out
    > > from cron. but i edit the cron file i found nothing on
    > > it.(i.e using pico filename.) Please tell me some
    > > description how to save the file in cron and to achive
    > > this. I will be thankful to you.
    > >
    > 
    > Instead of "ctrl+z", press ":wq" (colon for command mode, w for write, q for
    > quit). This assumes that vi is your default editor.
    > 
    
    And if you didn't know, you can set the VISUAL environment variable to
    change your default editor.  eg..
    
      export VISUAL=pico
    
    You can put this in your .profile to make it a default.  Personally I
    don't like line wrapping so I turn it off like this:
    
      export VISUAL='pico -w'
    
    You can also use the 'v' command in from 'less' to edit a file.. very
    handy..
    
    -Cedar