Обсуждение: is it possible to delete the psql log while psql is running?

Поиск
Список
Период
Сортировка

is it possible to delete the psql log while psql is running?

От
Gábor Farkas
Дата:
hi,

i'd like to delete the postgresql log file
(resides in /var/log/pgsql/postgres),
because it has become too big.

can i simply delete the file while postres is running?

or do i have to stop postgres first, and only delete the logfile after that?

thanks,
gabor

Re: is it possible to delete the psql log while psql is

От
Csaba Nagy
Дата:
Gabor,

Short answer: you'll have to restart.

Long answer:
It depends a lot on your OS... on windows I bet you can't delete it, the
OS will prevent you to do it (you'll get some error).
On Linux you can delete it, but the postgres server will still use it
even if you can't access it anymore (won't show up with ls)... the file
will be really deleted when the postgres server process dies. The only
effect you'll achieve is that you won't be able to access it anymore...
And if you want to do it for freeing up disk space, it won't do that.
So you better set up some kind of log rotation (I think you can do it
from the postgres config file), and restart your server.

Cheers,
Csaba.

On Thu, 2005-12-08 at 11:28, Gábor Farkas wrote:
> hi,
>
> i'd like to delete the postgresql log file
> (resides in /var/log/pgsql/postgres),
> because it has become too big.
>
> can i simply delete the file while postres is running?
>
> or do i have to stop postgres first, and only delete the logfile after that?
>
> thanks,
> gabor
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster


Re: is it possible to delete the psql log while psql is

От
Martijn van Oosterhout
Дата:
On Thu, Dec 08, 2005 at 02:43:44PM +0100, Csaba Nagy wrote:
> Gabor,
>
> Short answer: you'll have to restart.
>
> Long answer:
> It depends a lot on your OS... on windows I bet you can't delete it, the
> OS will prevent you to do it (you'll get some error).

Note: on Linux I've had success with simply truncating the file using:

: > [filename]

This does free up the space used straightaway. Depending on the mode
the file was opened with it may also reset the position the postmaster
writes at.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

Re: is it possible to delete the psql log while psql is

От
Csaba Nagy
Дата:
[snip]
> Note: on Linux I've had success with simply truncating the file using:
>
> : > [filename]
>
> This does free up the space used straightaway. Depending on the mode
> the file was opened with it may also reset the position the postmaster
> writes at.

Interesting hint, I'll try it next time I'll need such effect, although
I won't do it with any production data base ;-)

Thanks Martijn !

Cheers,
Csaba.