Linux logrotate, como configurar o logrotate para remover todos os logs com mais de um mês?

0

Temos servidores Linux Red Hat - versão 7.2. Temos os seguintes registros do Hive em /var/log/hive .

Como podemos configurar o logrotate do Linux para que todos os arquivos de log com mais de um mês sejam excluídos:

-rw-r--r--  1 hive hadoop    2427759 May  7 23:57 hiveserver2.log.2018-05-07
-rw-r--r--  1 hive hadoop    2428734 May  8 23:58 hiveserver2.log.2018-05-08
-rw-r--r--  1 hive hadoop    2428044 May  9 23:59 hiveserver2.log.2018-05-09
-rw-r--r--  1 hive hadoop    2427299 May 10 23:57 hiveserver2.log.2018-05-10
-rw-r--r--  1 hive hadoop    2428044 May 11 23:59 hiveserver2.log.2018-05-11
-rw-r--r--  1 hive hadoop    2427299 May 12 23:57 hiveserver2.log.2018-05-12
-rw-r--r--  1 hive hadoop    2407579 May 13 23:57 hiveserver2.log.2018-05-13
-rw-r--r--  1 hive hadoop    2427773 May 14 23:57 hiveserver2.log.2018-05-14
-rw-r--r--  1 hive hadoop    2428315 May 15 23:59 hiveserver2.log.2018-05-15
-rw-r--r--  1 hive hadoop    2427299 May 16 23:57 hiveserver2.log.2018-05-16
-rw-r--r--  1 hive hadoop    2428044 May 17 23:58 hiveserver2.log.2018-05-17
-rw-r--r--  1 hive hadoop    2427299 May 18 23:57 hiveserver2.log.2018-05-18
-rw-r--r--  1 hive hadoop    2428044 May 19 23:58 hiveserver2.log.2018-05-19
-rw-r--r--  1 hive hadoop    2427299 May 20 23:57 hiveserver2.log.2018-05-20
-rw-r--r--  1 hive hadoop    2428044 May 21 23:58 hiveserver2.log.2018-05-21
-rw-r--r--  1 hive hadoop    2427611 May 22 23:57 hiveserver2.log.2018-05-22
-rw-r--r--  1 hive hadoop    2428524 May 23 23:57 hiveserver2.log.2018-05-23
-rw-r--r--  1 hive hadoop    2427779 May 24 23:57 hiveserver2.log.2018-05-24
-rw-r--r--  1 hive hadoop    2428524 May 25 23:57 hiveserver2.log.2018-05-25
-rw-r--r--  1 hive hadoop    2427779 May 26 23:57 hiveserver2.log.2018-05-26
-rw-r--r--  1 hive hadoop    2423593 May 27 23:58 hiveserver2.log.2018-05-27
-rw-r--r--  1 hive hadoop    2427779 May 28 23:57 hiveserver2.log.2018-05-28
-rw-r--r--  1 hive hadoop    2428524 May 29 23:58 hiveserver2.log.2018-05-29
-rw-r--r--  1 hive hadoop    2427779 May 30 23:57 hiveserver2.log.2018-05-30
-rw-r--r--  1 hive hadoop    2418662 May 31 23:57 hiveserver2.log.2018-05-31
-rw-r--r--  1 hive hadoop    2428050 Jun  1 23:59 hiveserver2.log.2018-06-01
-rw-r--r--  1 hive hadoop    2428253 Jun  2 23:57 hiveserver2.log.2018-06-02
-rw-r--r--  1 hive hadoop    2428050 Jun  3 23:57 hiveserver2.log.2018-06-03
-rw-r--r--  1 hive hadoop    2428524 Jun  4 23:57 hiveserver2.log.2018-06-04
-rw-r--r--  1 hive hadoop    2428280 Jun  5 23:57 hiveserver2.log.2018-06-05
-rw-r--r--  1 hive hadoop    2403598 Jun  6 23:57 hiveserver2.log.2018-06-06
-rw-r--r--  1 hive hadoop    2428050 Jun  7 23:57 hiveserver2.log.2018-06-07
-rw-r--r--  1 hive hadoop    2428524 Jun  8 23:59 hiveserver2.log.2018-06-08
-rw-r--r--  1 hive hadoop    2428524 Jun  9 23:59 hiveserver2.log.2018-06-09
-rw-r--r--  1 hive hadoop    2427779 Jun 10 23:57 hiveserver2.log.2018-06-10
-rw-r--r--  1 hive hadoop    2428524 Jun 11 23:57 hiveserver2.log.2018-06-11
-rw-r--r--  1 hive hadoop    2428050 Jun 12 23:58 hiveserver2.log.2018-06-12
-rw-r--r--  1 hive hadoop    2428524 Jun 13 23:57 hiveserver2.log.2018-06-13
-rw-r--r--  1 hive hadoop    3071577 Jun 14 23:57 hiveserver2.log.2018-06-14
-rw-r--r--  1 hive hadoop    2428253 Jun 15 23:57 hiveserver2.log.2018-06-15
-rw-r--r--  1 hive hadoop    2428321 Jun 16 23:58 hiveserver2.log.2018-06-16
-rw-r--r--  1 hive hadoop    2423593 Jun 17 23:57 hiveserver2.log.2018-06-17
-rw-r--r--  1 hive hadoop    2417917 Jun 18 23:57 hiveserver2.log.2018-06-18
-rw-r--r--  1 hive hadoop    2426466 Jun 19 23:57 hiveserver2.log.2018-06-19
-rw-r--r--  1 hive hadoop    2428524 Jun 20 23:57 hiveserver2.log.2018-06-20
-rw-r--r--  1 hive hadoop    8886204 Jun 21 23:59 hiveserver2.log.2018-06-21
-rw-r--r--  1 hive hadoop   16072582 Jun 22 23:59 hiveserver2.log.2018-06-22
-rw-r--r--  1 hive hadoop   16050344 Jun 23 23:59 hiveserver2.log.2018-06-23
-rw-r--r--  1 hive hadoop    7206583 Jun 24 23:58 hiveserver2.log.2018-06-24
-rw-r--r--  1 hive hadoop    4091983 Jun 24 23:59 hivemetastore.log.2018-06-24
-rw-r--r--  1 hive hadoop    2428754 Jun 25 23:58 hiveserver2.log.2018-06-25
-rw-r--r--  1 hive hadoop    5207183 Jun 25 23:58 hivemetastore.log.2018-06-25
-rw-r--r--  1 hive hadoop    2452573 Jun 26 23:58 hiveserver2.log.2018-06-26
-rw-r--r--  1 hive hadoop    1593985 Jun 26 23:58 hivemetastore.log.2018-06-26
-rw-r--r--  1 hive hadoop    2649871 Jun 27 23:58 hiveserver2.log.2018-06-27
-rw-r--r--  1 hive hadoop    1252899 Jun 27 23:58 hivemetastore.log.2018-06-27
-rw-r--r--  1 hive hadoop    4056832 Jun 28 23:58 hiveserver2.log.2018-06-28
-rw-r--r--  1 hive hadoop    1239494 Jun 28 23:58 hivemetastore.log.2018-06-28
-rw-r--r--  1 hive hadoop    2457595 Jun 29 23:58 hiveserver2.log.2018-06-29
-rw-r--r--  1 hive hadoop    1190070 Jun 29 23:58 hivemetastore.log.2018-06-29
-rw-r--r--  1 hive hadoop    2456850 Jun 30 23:58 hiveserver2.log.2018-06-30
-rw-r--r--  1 hive hadoop    1190164 Jun 30 23:58 hivemetastore.log.2018-06-30
-rw-r--r--  1 hive hadoop    2618713 Jul  1 23:58 hiveserver2.log.2018-07-01
-rw-r--r--  1 hive hadoop    1764492 Jul  1 23:58 hivemetastore.log.2018-07-01
-rw-r--r--  1 hive hadoop    2428524 Jul  2 23:58 hiveserver2.log.2018-07-02
-rw-r--r--  1 hive hadoop    1189251 Jul  2 23:58 hivemetastore.log.2018-07-02
-rw-r--r--  1 hive hadoop    2428050 Jul  3 23:58 hiveserver2.log.2018-07-03
-rw-r--r--  1 hive hadoop    1377416 Jul  3 23:58 hivemetastore.log.2018-07-03
-rw-r--r--  1 hive hadoop    2530639 Jul  4 23:58 hiveserver2.log.2018-07-04
-rw-r--r--  1 hive hadoop    1278000 Jul  4 23:58 hivemetastore.log.2018-07-04
-rw-r--r--  1 hive hadoop    2428984 Jul  5 23:58 hiveserver2.log.2018-07-05
-rw-r--r--  1 hive hadoop    1197379 Jul  5 23:58 hivemetastore.log.2018-07-05
-rw-r--r--  1 hive hadoop    2428050 Jul  6 23:58 hiveserver2.log.2018-07-06
-rw-r--r--  1 hive hadoop    1189221 Jul  6 23:58 hivemetastore.log.2018-07-06
-rw-r--r--  1 hive hadoop    3027808 Jul  7 23:58 hiveserver2.log.2018-07-07
-rw-r--r--  1 hive hadoop    1186460 Jul  7 23:58 hivemetastore.log.2018-07-07
-rw-r--r--  1 hive hadoop    1313786 Jul  8 23:58 hivemetastore.log.2018-07-08
-rw-r--r--  1 hive hadoop    8491552 Jul  8 23:59 hiveserver2.log.2018-07-08
-rw-r--r--  1 hive hadoop     418648 Jul  9 23:58 hivemetastore.log.2018-07-09
-rw-r--r--  1 hive hadoop   13521450 Jul  9 23:59 hiveserver2.log.2018-07-09
-rw-r--r--  1 hive hadoop     403619 Jul 10 23:58 hivemetastore.log.2018-07-10
-rw-r--r--  1 hive hadoop    9516982 Jul 10 23:59 hiveserver2.log.2018-07-10
-rw-r--r--  1 hive hadoop     403650 Jul 11 23:58 hivemetastore.log.2018-07-11
-rw-r--r--  1 hive hadoop    9588437 Jul 11 23:59 hiveserver2.log.2018-07-11
-rw-r--r--  1 hive hadoop     403890 Jul 12 23:58 hivemetastore.log.2018-07-12
-rw-r--r--  1 hive hadoop    9636082 Jul 12 23:59 hiveserver2.log.2018-07-12
-rw-r--r--  1 hive hadoop     404364 Jul 13 23:58 hivemetastore.log.2018-07-13
-rw-r--r--  1 hive hadoop    9578278 Jul 13 23:59 hiveserver2.log.2018-07-13
-rw-r--r--  1 hive hadoop     403890 Jul 14 23:58 hivemetastore.log.2018-07-14
-rw-r--r--  1 hive hadoop    9505343 Jul 14 23:59 hiveserver2.log.2018-07-14
-rw-r--r--  1 hive hadoop     404093 Jul 15 23:58 hivemetastore.log.2018-07-15
-rw-r--r--  1 hive hadoop    9588093 Jul 15 23:59 hiveserver2.log.2018-07-15
-rw-r--r--  1 hive hadoop    5146008 Jul 16 23:58 hiveserver2.log.2018-07-16
-rw-r--r--  1 hive hadoop     968828 Jul 16 23:58 hivemetastore.log.2018-07-16
-rw-r--r--  1 hive hadoop    2470754 Jul 17 23:58 hiveserver2.log.2018-07-17
-rw-r--r--  1 hive hadoop    1276013 Jul 17 23:58 hivemetastore.log.2018-07-17
-rw-r--r--  1 hive hadoop    2428524 Jul 18 23:58 hiveserver2.log.2018-07-18
-rw-r--r--  1 hive hadoop    1392995 Jul 18 23:58 hivemetastore.log.2018-07-18
-rw-r--r--  1 hive hadoop    2542335 Jul 19 23:58 hiveserver2.log.2018-07-19
-rw-r--r--  1 hive hadoop    1589517 Jul 19 23:58 hivemetastore.log.2018-07-19
-rw-r--r--  1 hive hadoop    2468078 Jul 20 23:58 hiveserver2.log.2018-07-20
-rw-r--r--  1 hive hadoop    1390898 Jul 20 23:58 hivemetastore.log.2018-07-20
-rw-r--r--  1 hive hadoop    2467848 Jul 21 23:58 hiveserver2.log.2018-07-21
-rw-r--r--  1 hive hadoop    1223634 Jul 21 23:58 hivemetastore.log.2018-07-21
-rw-r--r--  1 hive hadoop    2553161 Jul 22 23:58 hiveserver2.log.2018-07-22
-rw-r--r--  1 hive hadoop    1495781 Jul 22 23:58 hivemetastore.log.2018-07-22
-rw-r--r--  1 hive hadoop    2466780 Jul 23 23:58 hiveserver2.log.2018-07-23
-rw-r--r--  1 hive hadoop    1439100 Jul 23 23:58 hivemetastore.log.2018-07-23
-rw-r--r--  1 hive hadoop    2467047 Jul 24 23:58 hiveserver2.log.2018-07-24
-rw-r--r--  1 hive hadoop    1439367 Jul 24 23:58 hivemetastore.log.2018-07-24
-rw-r--r--  1 hive hadoop    2452448 Jul 25 23:58 hiveserver2.log.2018-07-25
-rw-r--r--  1 hive hadoop    1433751 Jul 25 23:58 hivemetastore.log.2018-07-25
-rw-r--r--  1 hive hadoop    2466780 Jul 26 23:58 hiveserver2.log.2018-07-26
-rw-r--r--  1 hive hadoop    1456257 Jul 26 23:58 hivemetastore.log.2018-07-26
-rw-r--r--  1 hive hadoop    2466780 Jul 27 23:58 hiveserver2.log.2018-07-27
-rw-r--r--  1 hive hadoop    1439367 Jul 27 23:58 hivemetastore.log.2018-07-27
-rw-r--r--  1 hive hadoop    2466780 Jul 28 23:58 hiveserver2.log.2018-07-28
-rw-r--r--  1 hive hadoop    1439634 Jul 28 23:58 hivemetastore.log.2018-07-28
-rw-r--r--  1 hive hadoop    2653774 Jul 29 23:58 hiveserver2.log.2018-07-29
-rw-r--r--  1 hive hadoop    1623419 Jul 29 23:58 hivemetastore.log.2018-07-29
-rw-r--r--  1 hive hadoop    2701943 Jul 30 23:58 hiveserver2.log.2018-07-30
-rw-r--r--  1 hive hadoop    1448742 Jul 30 23:58 hivemetastore.log.2018-07-30
-rw-r--r--  1 hive hadoop    2701713 Jul 31 23:58 hiveserver2.log.2018-07-31
-rw-r--r--  1 hive hadoop    1474521 Jul 31 23:58 hivemetastore.log.2018-07-31
-rw-r--r--. 1 hive hadoop         31 Aug  1 16:14 hive.out
-rw-r--r--. 1 hive hadoop         83 Aug  1 16:14 hive.err
-rw-r--r--. 1 hive hadoop          0 Aug  1 16:15 hive-server2.out
-rw-r--r--. 1 hive hadoop         83 Aug  1 16:15 hive-server2.err
-rw-r--r--  1 hive hadoop    2131837 Aug  1 16:34 hiveserver2.log
-rw-r--r--  1 hive hadoop    1093248 Aug  1 16:34 hivemetastore.log
-rw-r--r--  1 hive hadoop       4346 Aug  1 16:36 hivemetastore-report.json.tmp
-rw-r--r--  1 hive hadoop       4438 Aug  1 16:36 hiveserver2-report.json.tmp

Resultados esperados:

-rw-r--r--  1 hive hadoop    2618713 Jul  1 23:58 hiveserver2.log.2018-07-01
-rw-r--r--  1 hive hadoop    1764492 Jul  1 23:58 hivemetastore.log.2018-07-01
-rw-r--r--  1 hive hadoop    2428524 Jul  2 23:58 hiveserver2.log.2018-07-02
-rw-r--r--  1 hive hadoop    1189251 Jul  2 23:58 hivemetastore.log.2018-07-02
-rw-r--r--  1 hive hadoop    2428050 Jul  3 23:58 hiveserver2.log.2018-07-03
-rw-r--r--  1 hive hadoop    1377416 Jul  3 23:58 hivemetastore.log.2018-07-03
-rw-r--r--  1 hive hadoop    2530639 Jul  4 23:58 hiveserver2.log.2018-07-04
-rw-r--r--  1 hive hadoop    1278000 Jul  4 23:58 hivemetastore.log.2018-07-04
-rw-r--r--  1 hive hadoop    2428984 Jul  5 23:58 hiveserver2.log.2018-07-05
-rw-r--r--  1 hive hadoop    1197379 Jul  5 23:58 hivemetastore.log.2018-07-05
-rw-r--r--  1 hive hadoop    2428050 Jul  6 23:58 hiveserver2.log.2018-07-06
-rw-r--r--  1 hive hadoop    1189221 Jul  6 23:58 hivemetastore.log.2018-07-06
-rw-r--r--  1 hive hadoop    3027808 Jul  7 23:58 hiveserver2.log.2018-07-07
-rw-r--r--  1 hive hadoop    1186460 Jul  7 23:58 hivemetastore.log.2018-07-07
-rw-r--r--  1 hive hadoop    1313786 Jul  8 23:58 hivemetastore.log.2018-07-08
-rw-r--r--  1 hive hadoop    8491552 Jul  8 23:59 hiveserver2.log.2018-07-08
-rw-r--r--  1 hive hadoop     418648 Jul  9 23:58 hivemetastore.log.2018-07-09
-rw-r--r--  1 hive hadoop   13521450 Jul  9 23:59 hiveserver2.log.2018-07-09
-rw-r--r--  1 hive hadoop     403619 Jul 10 23:58 hivemetastore.log.2018-07-10
-rw-r--r--  1 hive hadoop    9516982 Jul 10 23:59 hiveserver2.log.2018-07-10
-rw-r--r--  1 hive hadoop     403650 Jul 11 23:58 hivemetastore.log.2018-07-11
-rw-r--r--  1 hive hadoop    9588437 Jul 11 23:59 hiveserver2.log.2018-07-11
-rw-r--r--  1 hive hadoop     403890 Jul 12 23:58 hivemetastore.log.2018-07-12
-rw-r--r--  1 hive hadoop    9636082 Jul 12 23:59 hiveserver2.log.2018-07-12
-rw-r--r--  1 hive hadoop     404364 Jul 13 23:58 hivemetastore.log.2018-07-13
-rw-r--r--  1 hive hadoop    9578278 Jul 13 23:59 hiveserver2.log.2018-07-13
-rw-r--r--  1 hive hadoop     403890 Jul 14 23:58 hivemetastore.log.2018-07-14
-rw-r--r--  1 hive hadoop    9505343 Jul 14 23:59 hiveserver2.log.2018-07-14
-rw-r--r--  1 hive hadoop     404093 Jul 15 23:58 hivemetastore.log.2018-07-15
-rw-r--r--  1 hive hadoop    9588093 Jul 15 23:59 hiveserver2.log.2018-07-15
-rw-r--r--  1 hive hadoop    5146008 Jul 16 23:58 hiveserver2.log.2018-07-16
-rw-r--r--  1 hive hadoop     968828 Jul 16 23:58 hivemetastore.log.2018-07-16
-rw-r--r--  1 hive hadoop    2470754 Jul 17 23:58 hiveserver2.log.2018-07-17
-rw-r--r--  1 hive hadoop    1276013 Jul 17 23:58 hivemetastore.log.2018-07-17
-rw-r--r--  1 hive hadoop    2428524 Jul 18 23:58 hiveserver2.log.2018-07-18
-rw-r--r--  1 hive hadoop    1392995 Jul 18 23:58 hivemetastore.log.2018-07-18
-rw-r--r--  1 hive hadoop    2542335 Jul 19 23:58 hiveserver2.log.2018-07-19
-rw-r--r--  1 hive hadoop    1589517 Jul 19 23:58 hivemetastore.log.2018-07-19
-rw-r--r--  1 hive hadoop    2468078 Jul 20 23:58 hiveserver2.log.2018-07-20
-rw-r--r--  1 hive hadoop    1390898 Jul 20 23:58 hivemetastore.log.2018-07-20
-rw-r--r--  1 hive hadoop    2467848 Jul 21 23:58 hiveserver2.log.2018-07-21
-rw-r--r--  1 hive hadoop    1223634 Jul 21 23:58 hivemetastore.log.2018-07-21
-rw-r--r--  1 hive hadoop    2553161 Jul 22 23:58 hiveserver2.log.2018-07-22
-rw-r--r--  1 hive hadoop    1495781 Jul 22 23:58 hivemetastore.log.2018-07-22
-rw-r--r--  1 hive hadoop    2466780 Jul 23 23:58 hiveserver2.log.2018-07-23
-rw-r--r--  1 hive hadoop    1439100 Jul 23 23:58 hivemetastore.log.2018-07-23
-rw-r--r--  1 hive hadoop    2467047 Jul 24 23:58 hiveserver2.log.2018-07-24
-rw-r--r--  1 hive hadoop    1439367 Jul 24 23:58 hivemetastore.log.2018-07-24
-rw-r--r--  1 hive hadoop    2452448 Jul 25 23:58 hiveserver2.log.2018-07-25
-rw-r--r--  1 hive hadoop    1433751 Jul 25 23:58 hivemetastore.log.2018-07-25
-rw-r--r--  1 hive hadoop    2466780 Jul 26 23:58 hiveserver2.log.2018-07-26
-rw-r--r--  1 hive hadoop    1456257 Jul 26 23:58 hivemetastore.log.2018-07-26
-rw-r--r--  1 hive hadoop    2466780 Jul 27 23:58 hiveserver2.log.2018-07-27
-rw-r--r--  1 hive hadoop    1439367 Jul 27 23:58 hivemetastore.log.2018-07-27
-rw-r--r--  1 hive hadoop    2466780 Jul 28 23:58 hiveserver2.log.2018-07-28
-rw-r--r--  1 hive hadoop    1439634 Jul 28 23:58 hivemetastore.log.2018-07-28
-rw-r--r--  1 hive hadoop    2653774 Jul 29 23:58 hiveserver2.log.2018-07-29
-rw-r--r--  1 hive hadoop    1623419 Jul 29 23:58 hivemetastore.log.2018-07-29
-rw-r--r--  1 hive hadoop    2701943 Jul 30 23:58 hiveserver2.log.2018-07-30
-rw-r--r--  1 hive hadoop    1448742 Jul 30 23:58 hivemetastore.log.2018-07-30
-rw-r--r--  1 hive hadoop    2701713 Jul 31 23:58 hiveserver2.log.2018-07-31
-rw-r--r--  1 hive hadoop    1474521 Jul 31 23:58 hivemetastore.log.2018-07-31
-rw-r--r--. 1 hive hadoop         31 Aug  1 16:14 hive.out
-rw-r--r--. 1 hive hadoop         83 Aug  1 16:14 hive.err
-rw-r--r--. 1 hive hadoop          0 Aug  1 16:15 hive-server2.out
-rw-r--r--. 1 hive hadoop         83 Aug  1 16:15 hive-server2.err
-rw-r--r--  1 hive hadoop    2131837 Aug  1 16:34 hiveserver2.log
-rw-r--r--  1 hive hadoop    1093248 Aug  1 16:34 hivemetastore.log
-rw-r--r--  1 hive hadoop       4346 Aug  1 16:36 hivemetastore-report.json.tmp
-rw-r--r--  1 hive hadoop       4438 Aug  1 16:36 hiveserver2-report.json.tmp

o que eu fiz até agora é isso:

$ vi /etc/logrotate.conf

e adiciono essa configuração:

/var/log/hive {
    maxage 30
}

e execute isso:

$ logrotate /etc/logrotate.conf

para ter efeito. Mas isso não está funcionando?

Eu também configuro como

vi  /etc/logrotate.d/hive
/var/log/hive {

postrotate
        /usr/bin/find /var/log/hive -name "hive.log.*" -type f -mtime +21 -exec rm {} \;
endscript
}

mas essa abordagem não remove os arquivos com mais de 21 dias

também isso

/var/log/hive/*.log* {

postrotate
        /usr/bin/find /var/log/hive -name "*.log.*" -type f -mtime +21 -exec rm {} \;
endscript
}
    
por yael 01.08.2018 / 18:40

1 resposta

0

O padrão no seu logrotate nunca corresponderá a nenhum dos arquivos nomeados com o timestamp. Você precisa alterá-lo para corresponder.

Tente isto:

/var/log/hive/*.log* {
    maxage 30
}

Veja outros exemplos

Veja como os outros arquivos de configuração logrotate funcionam:

$ grep 'var/log' /etc/logrotate.d/* | head
/etc/logrotate.d/aide:/var/log/aide/*.log {
/etc/logrotate.d/bootlog:/var/log/boot.log
/etc/logrotate.d/chrony:/var/log/chrony/*.log {
/etc/logrotate.d/cups:/var/log/cups/*_log {
/etc/logrotate.d/glusterfs:/var/log/glusterfs/*.log {
/etc/logrotate.d/glusterfs:/var/log/glusterfs/bricks/*.log {
/etc/logrotate.d/glusterfs:/var/log/glusterfs/samples/*.samp {
/etc/logrotate.d/iscsiuiolog:/var/log/iscsiuio.log {
/etc/logrotate.d/libvirtd:/var/log/libvirt/libvirtd.log {
/etc/logrotate.d/libvirtd.qemu:/var/log/libvirt/qemu/*.log {

postrotate

A outra parte sobre isso que me incomoda é que você está tentando usar logrotate para rotacionar alguns arquivos de log de outros servidores, o que já tem um tipo de arquivo log4j girando. Isso é tipicamente uma receita para o desastre.

Por exemplo, você está lidando com o Hive, que faz parte do Hadoop. Todos os serviços do Hadoop têm seus próprios arquivos log4j.properties como este:

$ grep Back /etc/hadoop/conf/log4j.properties
#log4j.appender.DRFA.MaxBackupIndex=30
log4j.appender.RFAS.MaxBackupIndex=${hadoop.security.log.maxbackupindex}
log4j.appender.NNMETRICSRFA.MaxBackupIndex=1
log4j.appender.RFA.MaxBackupIndex=10
log4j.appender.RMSUMMARY.MaxBackupIndex=20

Nesses casos, eu recorro a fazer a "limpeza" assim:

/var/log/hive/* {
  ifempty
  size 0

postrotate
            /usr/bin/find /var/log/hive -name "*log*" -type f -mtime +29 -exec rm -f {} \;

endscript
}

Fazer isso dessa maneira permite o uso do comando find na regra de dias que você deseja usar.

Teste

Para verificar isso, usei as seguintes técnicas.

dados de amostra
$ for i in {01..31};do touch -t 07${i}1200 /var/log/hive/file${i}.log;done
teste executado
$ logrotate -v /etc/logrotate.d/hive |& tail -10
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/hive/file31.log.1 to /var/log/hive/file31.log.2 (rotatecount 1, logstart 1, i 1),
old log /var/log/hive/file31.log.1 does not exist
renaming /var/log/hive/file31.log.0 to /var/log/hive/file31.log.1 (rotatecount 1, logstart 1, i 0),
old log /var/log/hive/file31.log.0 does not exist
log /var/log/hive/file31.log.2 doesn't exist -- won't try to dispose of it
renaming /var/log/hive/file31.log to /var/log/hive/file31.log.1
disposeName will be /var/log/hive/file31.log.1
running postrotate script
removing old log /var/log/hive/file31.log.1

OBSERVAÇÃO: é seguro remover este ifempty & este size 0 , adicionei estes apenas para trabalhar com os meus dados falsos.

    
por 01.08.2018 / 19:04