Thread: Help

Help

From
Mohamed ebrahim
Date:
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/


Re: Help

From
Peter Eisentraut
Date:
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/



Re: Help

From
"Joe Conway"
Date:
>     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




Re: Help

From
"Richard Huxton"
Date:
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



Help

From
Mohamed ebrahim
Date:
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/


Re: Help

From
"Joe Conway"
Date:
>   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



Re: Help

From
selkovjr@mcs.anl.gov
Date:
> 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


Re: Help

From
Cedar Cox
Date:
> >   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