We have Linux Red Hat servers - version 7.2. We have the following Hive logs under /var/log/hive
.
How can we configure the Linux logrotate so every log file that's older than one month will be deleted:
-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
Expected results:
-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
what I did up until now is this:
$ vi /etc/logrotate.conf
and I add this configuration:
/var/log/hive {
maxage 30
}
and run this:
$ logrotate /etc/logrotate.conf
to take affect. But this isn't working?
I also set it as
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
}
but this approach not remove the files that older then 21 day
also this
/var/log/hive/*.log* {
postrotate
/usr/bin/find /var/log/hive -name "*.log.*" -type f -mtime +21 -exec rm {} \;
endscript
}