User Tools

Site Tools


linux:logrotate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
linux:logrotate [2020/03/21 06:25] kbadminlinux:logrotate [2020/03/21 06:33] kbadmin
Line 9: Line 9:
 <code> <code>
 logrotate -v logrotate -v
 +</code>
 +===== Default Setting =====
 +Adapun nilai default kita bisa melihatnya di **/etc/logrotate.conf**
 +<code>
 +cat /etc/logrotate.conf
 +</code>
 +# see "man logrotate" for details
 +# rotate log files weekly
 +weekly
 +
 +# keep 4 weeks worth of backlogs
 +rotate 4
 +
 +# create new (empty) log files after rotating old ones
 +create
 +
 +# use date as a suffix of the rotated file
 +dateext
 +
 +# uncomment this if you want your log files compressed
 +#compress
 +
 +# RPM packages drop log rotation information into this directory
 +include /etc/logrotate.d
 +
 +# no packages own wtmp and btmp -- we'll rotate them here
 +/var/log/wtmp {
 +    monthly
 +    create 0664 root utmp
 +        minsize 1M
 +    rotate 1
 +}
 +
 +/var/log/btmp {
 +    missingok
 +    monthly
 +    create 0600 root utmp
 +    rotate 1
 +}
 </code> </code>
  
 ===== Contoh 1 ===== ===== Contoh 1 =====
 +Kita ambil contoh dari syslog
 +<code>
 +cat /etc/logrotate.d/syslog
 +</code>
 +keluar
 +<code>
 +/var/log/cron
 +/var/log/maillog
 +/var/log/messages
 +/var/log/secure
 +/var/log/spooler
 +{
 +    sharedscripts
 +    postrotate
 +        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
 +    endscript
 +}
 +</code>
 +syslog akan merotasi file **cron,maillog,messages,secure dan spooler** mengikuti setting default yaitu weekly, rotate 4 dst
 +===== Contoh 2 =====
 <code> <code>
 /var/log/apt/history.log { /var/log/apt/history.log {
Line 27: Line 86:
 **notifempty** tidak akan dirotasi jika file log kosong **notifempty** tidak akan dirotasi jika file log kosong
  
-===== Contoh =====+===== Contoh =====
 <code> <code>
 /var/log/dir/*.log { /var/log/dir/*.log {
Line 43: Line 102:
 </code> </code>
  
-Merotasi semua file *.log yang terdapat didalam folder **/var/log/dir/** +Merotasi semua file *.log yang terdapat didalam folder **/var/log/dir/** \\ 
-**create 0640 apache apache** otomatis menciptakan file log kosong dengan owner adalah **apache** dan group **apache** +**create 0640 apache apache** otomatis menciptakan file log kosong dengan owner adalah **apache** dan group **apache** \\ 
-**sharedscripts** akan menjalankan script **systemctl reload example-app** sekali saja meskipun file log yang dirotasi lebih dari satu (*.log) +**sharedscripts** akan menjalankan script **systemctl reload example-app** sekali saja meskipun file log yang dirotasi lebih dari satu (*.log) \\ 
-**postrotate to endscript** adalah script yang akan dijalankan setelah rotasi selesai+**postrotate to endscript** adalah script yang akan dijalankan setelah rotasi selesai \\
  
  
  
 <nspages :linux:logrotate -h1 -textPages="Artikel" -exclude:sidebar -exclude:menu -exclude -simpleList> <nspages :linux:logrotate -h1 -textPages="Artikel" -exclude:sidebar -exclude:menu -exclude -simpleList>

Layanan

Harga Domain .COM | Harga Domain .ID | Shared Hosting | Email Hosting | MySQL Hosting |
linux/logrotate.txt · Last modified: 2020/03/21 06:43 by kbadmin

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki