質問編集履歴

3

追記

2019/04/19 04:43

投稿

gogoackman3
gogoackman3

スコア109

test CHANGED
File without changes
test CHANGED
@@ -159,3 +159,419 @@
159
159
 
160
160
 
161
161
  もしpumaのログローテーション方法がわかる方がいれば教えて頂けると嬉しいです。
162
+
163
+
164
+
165
+ #追記
166
+
167
+ 回答頂いた内容を踏まえ以下の通り実装し、24時間が経過し日付が変わったので、ローテーションされているか確認しました。
168
+
169
+
170
+
171
+
172
+
173
+ `/etc/logrotate.d/puma`の実装内容
174
+
175
+
176
+
177
+ ```ここに言語を入力
178
+
179
+ /var/log/puma/*log {
180
+
181
+ daily
182
+
183
+ missingok
184
+
185
+ rotate 5
186
+
187
+ ifempty
188
+
189
+ copytruncate
190
+
191
+ compress
192
+
193
+ delaycompress
194
+
195
+ create 0644 root root
196
+
197
+ su root root
198
+
199
+ }
200
+
201
+ ```
202
+
203
+ 結果としてはローテーションされていませんでした。。ファイルはアクセスログとエラーログがそれぞれ一つある状態のままです。
204
+
205
+
206
+
207
+ ```ここに言語を入力
208
+
209
+ ➜ puma pwd
210
+
211
+ /var/log/puma
212
+
213
+ ➜ puma ls
214
+
215
+ puma.stderr.log puma.stdout.log
216
+
217
+ ➜ puma ls -l
218
+
219
+ 合計 452
220
+
221
+ -rw-r--r-- 1 root root 222256 4月 19 03:22 puma.stderr.log
222
+
223
+ -rw-r--r-- 1 root root 228936 4月 19 04:20 puma.stdout.log
224
+
225
+ ```
226
+
227
+
228
+
229
+ 以下の通り、ステータスを確認すると、puma.stdout.logとpuma.stderr.logは4/19になっています。実装したのは4/18なので、ローテーションされている??ということでしょうか?
230
+
231
+
232
+
233
+ ```ここに言語を入力
234
+
235
+ ➜ /etc cat /var/lib/logrotate.status
236
+
237
+ logrotate state -- version 2
238
+
239
+ "/var/log/nginx/error.log" 2019-4-19
240
+
241
+ "/var/log/yum.log" 2019-4-18
242
+
243
+ "/var/log/redis/redis.log" 2019-4-14
244
+
245
+ "/var/log/dracut.log" 2017-3-24
246
+
247
+ "/var/log/puma/puma.stdout.log" 2019-4-19
248
+
249
+ "/var/lib/mysql/mysqld.log" 2017-3-25
250
+
251
+ "/var/log/monit" 2019-4-19
252
+
253
+ "/var/log/wtmp" 2017-3-24
254
+
255
+ "/var/log/spooler" 2019-4-14
256
+
257
+ "/var/log/puma/puma.stderr.log" 2019-4-19
258
+
259
+ "/var/log/btmp" 2019-4-1
260
+
261
+ "/var/log/maillog" 2019-4-14
262
+
263
+ "/var/log/secure" 2019-4-14
264
+
265
+ "/var/log/nginx/access.log" 2019-4-19
266
+
267
+ "/var/log/messages" 2019-4-14
268
+
269
+ "/var/account/pacct" 2017-3-24
270
+
271
+ "/var/log/cron" 2019-4-14
272
+
273
+ ```
274
+
275
+
276
+
277
+ 参考までに`/etc/logrotate.conf`は以下の通りです。
278
+
279
+
280
+
281
+ ```
282
+
283
+ ➜ sudo cat /etc/logrotate.conf
284
+
285
+ # see "man logrotate" for details
286
+
287
+ # rotate log files weekly
288
+
289
+ weekly
290
+
291
+
292
+
293
+ # keep 4 weeks worth of backlogs
294
+
295
+ rotate 4
296
+
297
+
298
+
299
+ # create new (empty) log files after rotating old ones
300
+
301
+ create
302
+
303
+
304
+
305
+ # use date as a suffix of the rotated file
306
+
307
+ dateext
308
+
309
+
310
+
311
+ # uncomment this if you want your log files compressed
312
+
313
+ #compress
314
+
315
+
316
+
317
+ # RPM packages drop log rotation information into this directory
318
+
319
+ include /etc/logrotate.d
320
+
321
+
322
+
323
+ # no packages own wtmp and btmp -- we'll rotate them here
324
+
325
+ /var/log/wtmp {
326
+
327
+ monthly
328
+
329
+ create 0664 root utmp
330
+
331
+ minsize 1M
332
+
333
+ rotate 1
334
+
335
+ }
336
+
337
+
338
+
339
+ /var/log/btmp {
340
+
341
+ missingok
342
+
343
+ monthly
344
+
345
+ create 0600 root utmp
346
+
347
+ rotate 1
348
+
349
+ }
350
+
351
+
352
+
353
+ # system-specific logs may be also be configured here.
354
+
355
+ ```
356
+
357
+
358
+
359
+
360
+
361
+ また[この記事](https://open-groove.net/linux/logrotate-test/)を参考に`/usr/sbin/logrotate -dv /etc/logrotate.conf`を実行すると結果は以下の通りでした。
362
+
363
+
364
+
365
+ ```ここに言語を入力
366
+
367
+ ➜ /usr/sbin/logrotate -dv /etc/logrotate.conf
368
+
369
+ reading config file /etc/logrotate.conf
370
+
371
+ including /etc/logrotate.d
372
+
373
+ Ignoring nginx.rpmnew, because of .rpmnew ending
374
+
375
+ reading config file dracut
376
+
377
+ reading config info for /var/log/dracut.log
378
+
379
+ reading config file monit
380
+
381
+ reading config info for /var/log/monit
382
+
383
+ reading config file mysql
384
+
385
+ reading config file nginx
386
+
387
+ reading config info for /var/log/nginx/*log
388
+
389
+ reading config file psacct
390
+
391
+ reading config info for /var/account/pacct
392
+
393
+ reading config file puma
394
+
395
+ reading config info for /var/log/puma/*log
396
+
397
+ error: puma:11 unknown option 'su' -- ignoring line
398
+
399
+ error: puma:11 unexpected text
400
+
401
+ reading config file redis
402
+
403
+ reading config info for /var/log/redis/redis.log
404
+
405
+ reading config file syslog
406
+
407
+ reading config info for /var/log/cron
408
+
409
+ /var/log/maillog
410
+
411
+ /var/log/messages
412
+
413
+ /var/log/secure
414
+
415
+ /var/log/spooler
416
+
417
+
418
+
419
+ reading config file yum
420
+
421
+ reading config info for /var/log/yum.log
422
+
423
+ reading config info for /var/log/wtmp
424
+
425
+ reading config info for /var/log/btmp
426
+
427
+
428
+
429
+ Handling 10 logs
430
+
431
+
432
+
433
+ rotating pattern: /var/log/dracut.log 1048576 bytes (4 rotations)
434
+
435
+ empty log files are not rotated, old logs are removed
436
+
437
+ considering log /var/log/dracut.log
438
+
439
+ log does not need rotating
440
+
441
+
442
+
443
+ rotating pattern: /var/log/monit 102400 bytes (4 rotations)
444
+
445
+ empty log files are not rotated, old logs are removed
446
+
447
+ considering log /var/log/monit
448
+
449
+ log does not need rotating
450
+
451
+ not running postrotate script, since no logs were rotated
452
+
453
+
454
+
455
+ rotating pattern: /var/log/nginx/*log after 1 days (52 rotations)
456
+
457
+ empty log files are not rotated, old logs are removed
458
+
459
+ considering log /var/log/nginx/access.log
460
+
461
+ log does not need rotating
462
+
463
+ considering log /var/log/nginx/error.log
464
+
465
+ log does not need rotating
466
+
467
+ not running postrotate script, since no logs were rotated
468
+
469
+
470
+
471
+ rotating pattern: /var/account/pacct after 1 days (31 rotations)
472
+
473
+ empty log files are not rotated, old logs are removed
474
+
475
+ considering log /var/account/pacct
476
+
477
+ log does not need rotating
478
+
479
+ not running postrotate script, since no logs were rotated
480
+
481
+
482
+
483
+ rotating pattern: /var/log/puma/*log after 1 days (5 rotations)
484
+
485
+ empty log files are rotated, old logs are removed
486
+
487
+ considering log /var/log/puma/puma.stderr.log
488
+
489
+ log does not need rotating
490
+
491
+ considering log /var/log/puma/puma.stdout.log
492
+
493
+ log does not need rotating
494
+
495
+
496
+
497
+ rotating pattern: /var/log/redis/redis.log weekly (10 rotations)
498
+
499
+ empty log files are not rotated, old logs are removed
500
+
501
+ considering log /var/log/redis/redis.log
502
+
503
+ log does not need rotating
504
+
505
+
506
+
507
+ rotating pattern: /var/log/cron
508
+
509
+ /var/log/maillog
510
+
511
+ /var/log/messages
512
+
513
+ /var/log/secure
514
+
515
+ /var/log/spooler
516
+
517
+ weekly (4 rotations)
518
+
519
+ empty log files are rotated, old logs are removed
520
+
521
+ considering log /var/log/cron
522
+
523
+ log does not need rotating
524
+
525
+ considering log /var/log/maillog
526
+
527
+ log does not need rotating
528
+
529
+ considering log /var/log/messages
530
+
531
+ log does not need rotating
532
+
533
+ considering log /var/log/secure
534
+
535
+ log does not need rotating
536
+
537
+ considering log /var/log/spooler
538
+
539
+ log does not need rotating
540
+
541
+ not running postrotate script, since no logs were rotated
542
+
543
+
544
+
545
+ rotating pattern: /var/log/yum.log yearly (4 rotations)
546
+
547
+ empty log files are not rotated, old logs are removed
548
+
549
+ considering log /var/log/yum.log
550
+
551
+ log does not need rotating
552
+
553
+
554
+
555
+ rotating pattern: /var/log/wtmp monthly (1 rotations)
556
+
557
+ empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
558
+
559
+ considering log /var/log/wtmp
560
+
561
+ log does not need rotating
562
+
563
+
564
+
565
+ rotating pattern: /var/log/btmp monthly (1 rotations)
566
+
567
+ empty log files are rotated, old logs are removed
568
+
569
+ considering log /var/log/btmp
570
+
571
+ log does not need rotating
572
+
573
+ ```
574
+
575
+
576
+
577
+ `/var/log/puma`の中にあるpuma.stdout.logとpuma.stderr.logの2ファイルはローテーションされているのでしょうか?おそらくされていないと思われるのですが、何か作成したファイルに問題がありますでしょうか?

2

誤字

2019/04/19 04:43

投稿

gogoackman3
gogoackman3

スコア109

test CHANGED
File without changes
test CHANGED
@@ -86,9 +86,9 @@
86
86
 
87
87
  config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
88
88
 
89
- config.logger = Logger.new("/var/log//puma/puma.stdout.log", 5, 10 * 1024 * 1024)
89
+ config.logger = Logger.new("/var/log/puma/puma.stdout.log", 5, 10 * 1024 * 1024)
90
90
 
91
- config.logger = Logger.new("/var/log//puma/puma.stderr.log", 5, 10 * 1024 * 1024)
91
+ config.logger = Logger.new("/var/log/puma/puma.stderr.log", 5, 10 * 1024 * 1024)
92
92
 
93
93
  ```
94
94
 

1

誤字の修正

2019/04/18 03:44

投稿

gogoackman3
gogoackman3

スコア109

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ```
10
10
 
11
- stdout_redirect "var/log/puma/puma.stdout.log", "var/log/puma/puma.stderr.log", true
11
+ stdout_redirect "/var/log/puma/puma.stdout.log", "/var/log/puma/puma.stderr.log", true
12
12
 
13
13
  ```
14
14