{"id":4287,"date":"2019-07-12T04:22:43","date_gmt":"2019-07-12T04:22:43","guid":{"rendered":"https:\/\/tst-amo.net.ua\/blog\/?p=4287"},"modified":"2022-10-08T06:22:43","modified_gmt":"2022-10-08T06:22:43","slug":"logrotate","status":"publish","type":"post","link":"https:\/\/tst-amo.net.ua\/blog\/?p=4287","title":{"rendered":"Logrotate"},"content":{"rendered":"<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 \/etc\/logrotate.conf, \u0430 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0\/etc\/logrotate.d<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<pre>\/var\/log\/name_service\/* {\r\n    rotate 30\r\n    size=10M\r\n    missingok\r\n    notifempty\r\n    daily  \r\n    compress\r\n    delaycompress\r\n    maxage 30\r\n    create 0644 root root\r\n    postrotate\r\n       \/usr\/bin\/systemctl restart logstash-forwarder\r\n    endscript\r\n}<\/pre>\n<ul>\n<li>rotate 30\u00a0\u2014 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30\u00a0\u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u044f\u0442\u044c.<\/li>\n<li>size=10M\u00a0\u2014 \u043f\u043e\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 10 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442, \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/li>\n<li>missingok\u00a0\u2014 \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u0435 \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/li>\n<li>notifempty\u00a0\u2014 \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043f\u0443\u0441\u0442\u043e\u0439, \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/li>\n<li>daily\u00a0\u2014 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u043e\u0442\u0430\u0446\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c.<\/li>\n<li>dateyesterday &#8211; \u0432\u0447\u0435\u0440\u0430\u0448\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u043f\u0440\u0438 \u0440\u043e\u0442\u0430\u0446\u0438\u0438<\/li>\n<li>dateext &#8211; \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u043e\u043c\u0435\u0440\u0430<\/li>\n<li>compress\u00a0\u2014 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.<\/li>\n<li>delaycompress\u00a0\u2014 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0436\u0443\u0440\u043d\u0430\u043b. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443.<\/li>\n<li>maxage 30\u00a0\u2014 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435\u00a0\u0444\u0430\u0439\u043b\u044b \u0437\u0430\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0434\u043d\u0435\u0439. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u044f\u0442\u044c.<\/li>\n<li>copytruncate &#8211; \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e log-\u0444\u0430\u0439\u043b\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e &#8216;\u043e\u0431\u043d\u0443\u043b\u0438\u0442\u044c&#8217;.\u00a0 \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0430\u043c \u0444\u0430\u0439\u043b\u00a0<strong><em class=\"u\">\u043d\u0435<\/em><\/strong> \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440. \u041d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c:\u00a0<em>create<\/em><\/li>\n<li>create 0644 root\u00a0root\u00a0\u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b \u043f\u043e\u0441\u043b\u0435 \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/li>\n<li>postrotate &#8230;\u00a0endscript\u00a0\u2014 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0447\u0438\u0441\u0442\u043a\u0438 \u043b\u043e\u0433\u0430.<\/li>\n<\/ul>\n<p>*\u00a0\/var\/log\/name_service\/*\u00a0\u2014 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. * \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435\u00a0\/var\/log\/name_service\/<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f ulog-acctd<\/h3>\n<pre>\/var\/log\/ulog-acctd\/account.log \/var\/log\/ulog-acctd\/debug.log {\r\n    daily\r\n    rotate 50\r\n    copytruncate\r\n    compress\r\n    notifempty\r\n    dateyesterday #\u0432\u0447\u0435\u0440\u0430\u0448\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u043f\u0440\u0438 \u0440\u043e\u0442\u0430\u0446\u0438\u0438\r\n    #dateext #\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u043e\u043c\u0435\u0440\u0430\r\n    missingok\r\n    sharedscripts\r\n    prerotate\r\n       if [ -e \/var\/run\/ulog-acctd.pid ]; then kill -TSTP `cat \/var\/run\/ulog-acctd.pid`; fi\r\n    endscript\r\n    postrotate\r\n       if [ -e \/var\/run\/ulog-acctd.pid ]; then kill -CONT `cat \/var\/run\/ulog-acctd.pid`; fi\r\n    endscript\r\n}<\/pre>\n<h3>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0440\u043e\u0442\u0430\u0446\u0438\u044f (\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\/\u043e\u0442\u043b\u0430\u0434\u043a\u0430)<\/h3>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435\u00a0logrotate\u00a0(\u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435):<\/p>\n<pre>$ logrotate -vdf <strong>CONFIG_FILE<\/strong><\/pre>\n<p>\u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre># \/usr\/sbin\/logrotate -d \/etc\/logrotate.conf 2&gt; \/tmp\/logrotate.debug\r\n<\/pre>\n<h3>\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u00a0logrotate:<\/h3>\n<pre>$ logrotate -vf <strong>CONFIG_FILE<\/strong><\/pre>\n<p>\u041e\u043f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0435\u00a0logrotate:<\/p>\n<p>-d, &#8211;debug\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c logrotate \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 (\u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043e\u043d).<br \/>\n-f, &#8211;force\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c logrotate.<br \/>\n-v, &#8211;verbose\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p class=\"note-blue\">\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0446\u0438\u0438 -f, &#8211;force,\u00a0logrotate\u00a0\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u043e\u0442\u0430\u0446\u0438\u044e \u0444\u0430\u0439\u043b\u043e\u0432, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u043a\u0430\u043a\u00a0<em>minsize<\/em>,\u00a0<em>age<\/em>\u00a0\u0438 \u0442.\u043f.<\/p>\n<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-bottom-right\"><a href=\"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=wpv2posts4287&print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/tst-amo.net.ua\/blog\/wp-content\/plugins\/pdf-print\/images\/pdf.png\" alt=\"image_pdf\" title=\"View PDF\" \/><\/a><a href=\"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=wpv2posts4287&print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/tst-amo.net.ua\/blog\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 \/etc\/logrotate.conf, \u0430 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0\/etc\/logrotate.d \u041f\u0440\u0438\u043c\u0435\u0440 \/var\/log\/name_service\/* { rotate 30 size=10M missingok notifempty daily compress delaycompress maxage 30 create 0644 root root postrotate \/usr\/bin\/systemctl restart logstash-forwarder endscript } rotate 30\u00a0\u2014 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30\u00a0\u0440\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u044f\u0442\u044c. size=10M\u00a0\u2014 \u043f\u043e\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 10 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442, &#8230;<\/p>\n<p><a href=\"https:\/\/tst-amo.net.ua\/blog\/?p=4287\" class=\"more-link\">Continue reading &lsquo;Logrotate&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,47,242,283],"tags":[],"class_list":["post-4287","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","category-log","category-logrotate"],"_links":{"self":[{"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4287"}],"collection":[{"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4287"}],"version-history":[{"count":8,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4287\/revisions"}],"predecessor-version":[{"id":5313,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4287\/revisions\/5313"}],"wp:attachment":[{"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tst-amo.net.ua\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}