{"id":311,"date":"2025-07-04T12:11:53","date_gmt":"2025-07-04T12:11:53","guid":{"rendered":"https:\/\/blog.chaiyakul.com\/?p=311"},"modified":"2025-07-04T12:11:53","modified_gmt":"2025-07-04T12:11:53","slug":"make-shell-script-del-log-sub-folder-centos9","status":"publish","type":"post","link":"https:\/\/blog.chaiyakul.com\/index.php\/2025\/07\/04\/make-shell-script-del-log-sub-folder-centos9\/","title":{"rendered":"\u0e2a\u0e23\u0e49\u0e32\u0e07 Shell Script \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c .log \u0e43\u0e19\u0e41\u0e1f\u0e49\u0e21\u0e22\u0e48\u0e2d\u0e22 CentOS9"},"content":{"rendered":"\n<p>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e33\u0e07\u0e32\u0e19<\/p>\n\n\n\n<p>1. \u0e2a\u0e23\u0e49\u0e32\u0e07 Shell Script \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c <code>.log<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n\n# \u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c .log \u0e17\u0e35\u0e48\u0e40\u0e01\u0e48\u0e32\u0e01\u0e27\u0e48\u0e32 5 \u0e27\u0e31\u0e19 \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e43\u0e19\u0e41\u0e1f\u0e49\u0e21\u0e22\u0e48\u0e2d\u0e22\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\nfind \/var\/www\/html\/mill-app.com\/stream -type f -name &quot;*.log&quot; -mtime +5 -exec rm -f {} \\;\n<\/pre><\/div>\n\n\n<p>\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e41\u0e25\u0e49\u0e27\u0e43\u0e2b\u0e49\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e23\u0e31\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo chmod +x \/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>2. \u0e2a\u0e23\u0e49\u0e32\u0e07 Systemd Service<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/systemd\/system\/clean-log-stream.service\n<\/pre><\/div>\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription=Clean old log files in stream folder\nAfter=network.target\n\n&#x5B;Service]\nType=oneshot\nExecStart=\/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>3.\u0e15\u0e31\u0e49\u0e07\u0e43\u0e2b\u0e49\u0e23\u0e31\u0e19\u0e17\u0e38\u0e01\u0e04\u0e23\u0e31\u0e49\u0e07\u0e17\u0e35\u0e48\u0e1a\u0e39\u0e15 (\u0e1c\u0e48\u0e32\u0e19 systemd)<\/p>\n\n\n\n<p>\u0e2a\u0e23\u0e49\u0e32\u0e07 Timer:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/systemd\/system\/clean-log-stream.timer\n<\/pre><\/div>\n\n\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription=Run clean-log-stream.service at boot\n\n&#x5B;Timer]\nOnBootSec=5min\nAccuracySec=1min\n\n&#x5B;Install]\nWantedBy=timers.target\n<\/pre><\/div>\n\n\n<p>\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>OnBootSec=5min<\/code> \u2794 \u0e43\u0e2b\u0e49\u0e23\u0e31\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e1a\u0e39\u0e15\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07 5 \u0e19\u0e32\u0e17\u0e35<\/li>\n\n\n\n<li>\u0e1b\u0e23\u0e31\u0e1a\u0e40\u0e27\u0e25\u0e32\u0e44\u0e14\u0e49\u0e15\u0e32\u0e21\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23<\/li>\n<\/ul>\n\n\n\n<p>4.\u0e40\u0e1b\u0e34\u0e14\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 Timer<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl daemon-reload\nsudo systemctl enable clean-log-stream.timer\nsudo systemctl start clean-log-stream.timer\n<\/pre><\/div>\n\n\n<p>5.\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e27\u0e48\u0e32 Timer \u0e17\u0e33\u0e07\u0e32\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl list-timers --all | grep clean-log-stream\n<\/pre><\/div>\n\n\n<p>\u0e2a\u0e23\u0e38\u0e1b<\/p>\n\n\n\n<p>\u2705 \u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c <code>.log<\/code> \u0e17\u0e35\u0e48\u0e40\u0e01\u0e48\u0e32\u0e01\u0e27\u0e48\u0e32 5 \u0e27\u0e31\u0e19\u0e43\u0e19 <code>\/var\/www\/html\/mill-app.com\/stream<\/code><br>\u2705 \u0e04\u0e23\u0e2d\u0e1a\u0e04\u0e25\u0e38\u0e21\u0e17\u0e38\u0e01\u0e41\u0e1f\u0e49\u0e21\u0e22\u0e48\u0e2d\u0e22<br>\u2705 \u0e23\u0e31\u0e19\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34\u0e2b\u0e25\u0e31\u0e07\u0e1a\u0e39\u0e15\u0e17\u0e38\u0e01\u0e04\u0e23\u0e31\u0e49\u0e07<br>\u2705 \u0e43\u0e0a\u0e49 systemd \u0e41\u0e1a\u0e1a\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e41\u0e25\u0e30\u0e21\u0e35\u0e01\u0e32\u0e23\u0e04\u0e27\u0e1a\u0e04\u0e38\u0e21<\/p>\n\n\n\n<p>\u0e15\u0e31\u0e27\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e40\u0e2a\u0e23\u0e34\u0e21<\/p>\n\n\n\n<p>\u0e16\u0e49\u0e32\u0e2d\u0e22\u0e32\u0e01\u0e43\u0e2b\u0e49\u0e25\u0e39\u0e1b\u0e17\u0e33\u0e07\u0e32\u0e19\u0e17\u0e38\u0e01\u0e27\u0e31\u0e19\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34 \u0e40\u0e1e\u0e34\u0e48\u0e21\u0e43\u0e19 Timer \u0e44\u0e14\u0e49 \u0e40\u0e0a\u0e48\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nOnCalendar=daily\n<\/pre><\/div>\n\n\n<p>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14<\/p>\n\n\n\n<p>1.\u0e2a\u0e23\u0e49\u0e32\u0e07 Shell Script<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n\n# \u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c .log \u0e17\u0e35\u0e48\u0e40\u0e01\u0e48\u0e32\u0e01\u0e27\u0e48\u0e32 5 \u0e27\u0e31\u0e19 \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e43\u0e19\u0e41\u0e1f\u0e49\u0e21\u0e22\u0e48\u0e2d\u0e22\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\nfind \/var\/www\/html\/mill-app.com\/stream -type f -name &quot;*.log&quot; -mtime +5 -exec rm -f {} \\;\n<\/pre><\/div>\n\n\n<p>\u0e43\u0e2b\u0e49\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e23\u0e31\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo chmod +x \/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>2.\u0e2a\u0e23\u0e49\u0e32\u0e07 Service<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/systemd\/system\/clean-log-stream.service\n<\/pre><\/div>\n\n\n<p>\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription=Clean old log files in stream folder\nAfter=network.target\n\n&#x5B;Service]\nType=oneshot\nExecStart=\/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>3.\u0e2a\u0e23\u0e49\u0e32\u0e07 Timer<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/systemd\/system\/clean-log-stream.timer\n<\/pre><\/div>\n\n\n<p>\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription=Run clean-log-stream.service daily and at boot\n\n&#x5B;Timer]\n# \u0e23\u0e31\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e1a\u0e39\u0e15\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07 5 \u0e19\u0e32\u0e17\u0e35\nOnBootSec=5min\n\n# \u0e23\u0e31\u0e19\u0e17\u0e38\u0e01\u0e27\u0e31\u0e19\u0e40\u0e27\u0e25\u0e32 03:00 AM (\u0e1b\u0e23\u0e31\u0e1a\u0e40\u0e27\u0e25\u0e32\u0e44\u0e14\u0e49\u0e15\u0e32\u0e21\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23)\nOnCalendar=*-*-* 03:00:00\n\n# \u0e1b\u0e23\u0e31\u0e1a\u0e04\u0e27\u0e32\u0e21\u0e41\u0e21\u0e48\u0e19\u0e22\u0e33\u0e02\u0e2d\u0e07\u0e40\u0e27\u0e25\u0e32\nAccuracySec=1min\n\n&#x5B;Install]\nWantedBy=timers.target\n<\/pre><\/div>\n\n\n<p>4.\u0e42\u0e2b\u0e25\u0e14\u0e41\u0e25\u0e30\u0e40\u0e1b\u0e34\u0e14\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl daemon-reload\nsudo systemctl enable clean-log-stream.timer\nsudo systemctl start clean-log-stream.timer\n<\/pre><\/div>\n\n\n<p>5.\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a Timer<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl list-timers --all | grep clean-log-stream\n<\/pre><\/div>\n\n\n<p>\u0e08\u0e30\u0e40\u0e2b\u0e47\u0e19\u0e15\u0e32\u0e23\u0e32\u0e07\u0e40\u0e27\u0e25\u0e32\u0e23\u0e31\u0e19\u0e02\u0e2d\u0e07 Timer<\/p>\n\n\n\n<p>\u0e2a\u0e23\u0e38\u0e1b:<\/p>\n\n\n\n<p>\u2705 \u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c <code>.log<\/code> \u0e17\u0e35\u0e48\u0e40\u0e01\u0e48\u0e32\u0e01\u0e27\u0e48\u0e32 5 \u0e27\u0e31\u0e19\u0e43\u0e19 <code>\/var\/www\/html\/mill-app.com\/stream<\/code><br>\u2705 \u0e04\u0e23\u0e2d\u0e1a\u0e04\u0e25\u0e38\u0e21\u0e17\u0e38\u0e01\u0e41\u0e1f\u0e49\u0e21\u0e22\u0e48\u0e2d\u0e22<br>\u2705 \u0e23\u0e31\u0e19\u0e17\u0e38\u0e01\u0e27\u0e31\u0e19\u0e15\u0e2d\u0e19\u0e15\u0e35 3<br>\u2705 \u0e23\u0e31\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e1a\u0e39\u0e15\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07 5 \u0e19\u0e32\u0e17\u0e35<br>\u2705 \u0e04\u0e27\u0e1a\u0e04\u0e38\u0e21\u0e1c\u0e48\u0e32\u0e19 systemd \u0e2a\u0e30\u0e14\u0e27\u0e01 \u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22<\/p>\n\n\n\n<p><u><strong>\u0e2a\u0e23\u0e38\u0e1b\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19<\/strong><\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e1a\u0e39\u0e15\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07<br>\u2794 \u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e23\u0e30\u0e1a\u0e1a\u0e40\u0e2a\u0e16\u0e35\u0e22\u0e23\u0e41\u0e25\u0e49\u0e27 5 \u0e19\u0e32\u0e17\u0e35 <code>clean-log-stream.service<\/code> \u0e08\u0e30\u0e16\u0e39\u0e01\u0e23\u0e31\u0e19<\/li>\n\n\n\n<li>\u0e17\u0e38\u0e01\u0e27\u0e31\u0e19\u0e40\u0e27\u0e25\u0e32 03:00 AM<br>\u2794 \u0e08\u0e30\u0e23\u0e31\u0e19 <code>clean-log-stream.service<\/code> \u0e2d\u0e35\u0e01\u0e23\u0e2d\u0e1a<\/li>\n\n\n\n<li>\u0e15\u0e31\u0e27 Timer \u0e40\u0e2d\u0e07\u0e17\u0e33\u0e07\u0e32\u0e19\u0e40\u0e1a\u0e37\u0e49\u0e2d\u0e07\u0e2b\u0e25\u0e31\u0e07 systemd<br>\u2794 \u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e43\u0e0a\u0e49 <code>cron<\/code><\/li>\n<\/ol>\n\n\n\n<p><u><strong>\ud83d\udd17 \u0e01\u0e32\u0e23\u0e42\u0e22\u0e07\u0e23\u0e30\u0e2b\u0e27\u0e48\u0e32\u0e07 <code>.timer<\/code> \u0e41\u0e25\u0e30 <code>.service<\/code><\/strong><\/u><\/p>\n\n\n\n<p>\u0e43\u0e19\u0e23\u0e30\u0e1a\u0e1a <code>systemd<\/code>:<\/p>\n\n\n\n<p>\u2705 \u0e16\u0e49\u0e32\u0e44\u0e1f\u0e25\u0e4c <code>.timer<\/code> \u0e01\u0e31\u0e1a\u0e44\u0e1f\u0e25\u0e4c <code>.service<\/code><br><strong>\u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19\u0e01\u0e31\u0e19\u0e15\u0e23\u0e07\u0e2b\u0e19\u0e49\u0e32 <code>.timer<\/code> \u0e41\u0e25\u0e30 <code>.service<\/code><\/strong><br>\u0e23\u0e30\u0e1a\u0e1a\u0e08\u0e30\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e42\u0e22\u0e07\u0e43\u0e2b\u0e49\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34<\/p>\n\n\n\n<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e02\u0e2d\u0e07\u0e40\u0e23\u0e32:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Timer \u0e0a\u0e37\u0e48\u0e2d <code>clean-log-stream.timer<\/code><\/li>\n\n\n\n<li>Service \u0e0a\u0e37\u0e48\u0e2d <code>clean-log-stream.service<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u2728 systemd \u0e23\u0e39\u0e49\u0e42\u0e14\u0e22\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34\u0e27\u0e48\u0e32<\/p>\n\n\n\n<p><code>clean-log-stream.timer<\/code> \u0e08\u0e30\u0e44\u0e1b\u0e2a\u0e31\u0e48\u0e07 <code>clean-log-stream.service<\/code> \u0e17\u0e33\u0e07\u0e32\u0e19\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e16\u0e36\u0e07\u0e40\u0e27\u0e25\u0e32<\/p>\n\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e25\u0e33\u0e14\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19\u0e08\u0e23\u0e34\u0e07<\/p>\n\n\n\n<p>1.\u0e16\u0e36\u0e07\u0e40\u0e27\u0e25\u0e32\u0e17\u0e35\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e43\u0e19 <code>clean-log-stream.timer<\/code> \u0e40\u0e0a\u0e48\u0e19<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e2b\u0e25\u0e31\u0e07\u0e1a\u0e39\u0e15 5 \u0e19\u0e32\u0e17\u0e35 (\u0e08\u0e32\u0e01 <code>OnBootSec=5min<\/code>)<\/li>\n\n\n\n<li>\u0e2b\u0e23\u0e37\u0e2d\u0e17\u0e38\u0e01\u0e27\u0e31\u0e19 03:00 AM (\u0e08\u0e32\u0e01 <code>OnCalendar=*-*-* 03:00:00<\/code>)<\/li>\n<\/ul>\n\n\n\n<p>2.systemd \u0e08\u0e30 &#8220;\u0e44\u0e1b\u0e40\u0e23\u0e35\u0e22\u0e01&#8221;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl start clean-log-stream.service\n<\/pre><\/div>\n\n\n<p>3.\u0e0b\u0e36\u0e48\u0e07\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32\u0e43\u0e19 <code>clean-log-stream.service<\/code> \u0e04\u0e37\u0e2d<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Service]\nType=oneshot\nExecStart=\/usr\/local\/bin\/clean-log-stream.sh\n<\/pre><\/div>\n\n\n<p>\u0e2b\u0e21\u0e32\u0e22\u0e16\u0e36\u0e07\u0e2a\u0e31\u0e48\u0e07\u0e43\u0e2b\u0e49 <code>\/usr\/local\/bin\/clean-log-stream.sh<\/code> \u0e23\u0e31\u0e19 1 \u0e23\u0e2d\u0e1a \u0e41\u0e25\u0e49\u0e27\u0e08\u0e1a<\/p>\n\n\n\n<p>\ud83d\udccc \u0e2a\u0e23\u0e38\u0e1b:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e44\u0e21\u0e48\u0e21\u0e35\u0e01\u0e32\u0e23\u0e23\u0e30\u0e1a\u0e38\u0e0a\u0e37\u0e48\u0e2d Service \u0e0b\u0e49\u0e33\u0e43\u0e19\u0e44\u0e1f\u0e25\u0e4c <code>.timer<\/code><\/li>\n\n\n\n<li>systemd \u0e43\u0e0a\u0e49\u0e2b\u0e25\u0e31\u0e01 &#8220;\u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e1f\u0e25\u0e4c\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19&#8221; \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21<\/li>\n\n\n\n<li>\u0e16\u0e49\u0e32\u0e2d\u0e22\u0e32\u0e01\u0e43\u0e2b\u0e49 Timer \u0e2a\u0e31\u0e48\u0e07\u0e23\u0e31\u0e19 Service \u0e2d\u0e37\u0e48\u0e19 \u0e43\u0e2b\u0e49\u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e15\u0e23\u0e07\u0e01\u0e31\u0e19 \u0e2b\u0e23\u0e37\u0e2d\u0e43\u0e0a\u0e49 <code>Unit=<\/code> \u0e23\u0e30\u0e1a\u0e38 Service \u0e17\u0e35\u0e48\u0e08\u0e30\u0e2a\u0e31\u0e48\u0e07\u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19 (\u0e01\u0e23\u0e13\u0e35\u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e21\u0e48\u0e15\u0e23\u0e07)<\/li>\n<\/ul>\n\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e02\u0e31\u0e49\u0e19\u0e2a\u0e39\u0e07 (\u0e44\u0e21\u0e48\u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e15\u0e23\u0e07)<\/p>\n\n\n\n<p>\u0e16\u0e49\u0e32\u0e2d\u0e22\u0e32\u0e01\u0e43\u0e2b\u0e49 Timer \u0e2a\u0e31\u0e48\u0e07\u0e23\u0e31\u0e19 Service \u0e2d\u0e37\u0e48\u0e19 \u0e40\u0e0a\u0e48\u0e19:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Timer]\nOnBootSec=5min\nUnit=my-other-cleaner.service\n<\/pre><\/div>\n\n\n<p>\u0e41\u0e1a\u0e1a\u0e19\u0e35\u0e49 <code>my-other-cleaner.service<\/code> \u0e08\u0e30\u0e16\u0e39\u0e01\u0e40\u0e23\u0e35\u0e22\u0e01\u0e41\u0e17\u0e19<\/p>\n\n\n\n<p>\u0e2a\u0e23\u0e38\u0e1b\u0e07\u0e48\u0e32\u0e22\u0e2a\u0e38\u0e14:<\/p>\n\n\n\n<p>\u0e15\u0e2d\u0e19\u0e19\u0e35\u0e49 <code>clean-log-stream.timer<\/code> \u0e41\u0e25\u0e30 <code>clean-log-stream.service<\/code> \u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19\u0e01\u0e31\u0e19<br>\u0e23\u0e30\u0e1a\u0e1a\u0e08\u0e36\u0e07\u0e42\u0e22\u0e07\u0e43\u0e2b\u0e49\u0e40\u0e2d\u0e07 \u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e15\u0e31\u0e49\u0e07\u0e2d\u0e30\u0e44\u0e23\u0e40\u0e1e\u0e34\u0e48\u0e21<\/p>\n\n\n\n<p>\u0e16\u0e49\u0e32\u0e2d\u0e22\u0e32\u0e01\u0e25\u0e2d\u0e07\u0e14\u0e39\u0e27\u0e48\u0e32 Timer \u0e23\u0e31\u0e19\u0e25\u0e48\u0e32\u0e2a\u0e38\u0e14\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e44\u0e2b\u0e23\u0e48 \u0e43\u0e0a\u0e49:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl list-timers --all | grep clean-log-stream\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e33\u0e07\u0e32\u0e19 1. \u0e2a\u0e23\u0e49\u0e32\u0e07 Shell Script \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e25\u0e1a\u0e44\u0e1f\u0e25\u0e4c .log \u0e15\u0e31 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"categories":[105,9,160],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","category-service"],"_links":{"self":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":1,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/311\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}