2024年5月10日发(作者:)

主题:postgres数据库维护方法

1、首先登录服务器,用postgres用户,在/export/home/postgres下执行crontab

–l命令查看

bash-2.05$ crontab -l

11 * * * * /export/home/postgres/ hour

38 6 * * * /export/home/postgres/ daily

这两行命令是根据规定时间自动运行删除优化数据库。(其中蓝字分别代表分钟、小时、

天、月、星期)crontab--操作系统的定时调度器

用命令ls –al查看:

bash-2.05$ ls -al

total 36608

drwxr-xr-x 10 postgres postgres 512 Dec 29 09:42 .

drwxr-xr-x 8 root root 512 Dec 29 09:35 ..

-rw------- 1 postgres postgres 5179 Apr 14 19:55 .bash_history

-rw-r--r-- 1 postgres postgres 365 Apr 10 2004 .profile

-rw------- 1 postgres postgres 1575 Feb 2 18:02 .psql_history

drwxr-xr-x 2 postgres postgres 1024 Dec 29 09:31 bin

-rw-r--r--

-rw-r--r--

-rw-r--r--

-rw-r--r--

drwx------

drwxr-xr-x

drwxr-xr-x

drwxr-xr-x

-rw-r--r--

-rw-r--r--

3088 Aug 13 2004

3090 Jul 27 2004

54574 Apr 15 06:42

Apr 15 09:16

6 postgres postgres 512 Dec 28 16:23 data

3 postgres postgres 512 Apr 10 2004 doc

5 postgres postgres 512 Apr 10 2004 include

2 postgres postgres 1536 Apr 10 2004 lib

136 Apr 10 2004

157 Apr 10 2004

1 postgres postgres

1 postgres postgres

1 postgres postgres

1 postgres postgres 1304310

1 postgres postgres

1 postgres postgres