<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Shell on Zayn's Blog</title><link>https://blog.treesir.pub/tags/shell/</link><description>Recent content in Shell on Zayn's Blog</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><managingEditor>yangzun@treesir.pub (Zayn)</managingEditor><webMaster>yangzun@treesir.pub (Zayn)</webMaster><copyright>2021-2026 Zayn</copyright><lastBuildDate>Fri, 02 Dec 2022 15:12:34 +0800</lastBuildDate><atom:link href="https://blog.treesir.pub/tags/shell/index.xml" rel="self" type="application/rss+xml"/><item><title>使用 Cronjob 定时清理 ElasticSearch 中的日志索引</title><link>https://blog.treesir.pub/posts/cronjob-clean-es-index/</link><pubDate>Tue, 13 Jul 2021 11:45:00 +0800</pubDate><author>yangzun@treesir.pub (Zayn)</author><guid>https://blog.treesir.pub/posts/cronjob-clean-es-index/</guid><description>&lt;h2 class="relative group">背景
&lt;div id="背景" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#%e8%83%8c%e6%99%af" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h2>
&lt;blockquote>
&lt;p>在日常使用 &lt;code>efk&lt;/code> 日志系统的过程中，每天造成的日志索引量是巨大的，需要进行对相关的索引进行定期清理，来缓解后端储存的占用。如何实现在 kubernetes 中进行优雅的定期清理？本文将介绍使用 kubernetes 中的 &lt;code>Cronjob&lt;/code> 资源对象进行其需求的实现。&lt;/p>&lt;/blockquote>
&lt;p>&lt;strong>常规情况下清理 &lt;code>n&lt;/code> day 以前的数据&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl -XDELETE http://elasticsearch-logging.kube-system:9200/logstash-&lt;span class="sb">`&lt;/span>date -d&lt;span class="s2">&amp;#34;n days ago&amp;#34;&lt;/span> +&lt;span class="s2">&amp;#34;%Y.%m.%d&amp;#34;&lt;/span>&lt;span class="sb">`&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>这种方法，是网上比较常规的方式，如某一天忘记执行了，就会出现数据未清理干净的情况，有点不优雅，如何解决？&lt;/p></description></item><item><title>Centos7 执行 shutdown 无法正常关机的解决</title><link>https://blog.treesir.pub/posts/centos-shutdown-notpoweroff/</link><pubDate>Wed, 14 Apr 2021 10:48:42 +0800</pubDate><author>yangzun@treesir.pub (Zayn)</author><guid>https://blog.treesir.pub/posts/centos-shutdown-notpoweroff/</guid><description>&lt;h2 class="relative group">环境说明
&lt;div id="环境说明" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#%e7%8e%af%e5%a2%83%e8%af%b4%e6%98%8e" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h2>
&lt;blockquote>
&lt;p>因为在公司中，有下班后有需要关闭 &lt;code>服务器&lt;/code> 的操作，并且每天还需要去手动打开。有点违背 极客精神，所有自己通过 &lt;code>shell script&lt;/code> + &lt;code>cron&lt;/code> 的形式进行每天定时的 &lt;code>开关服务器机&lt;/code> 操作。但是服务器中不乏有一些比较老的机型，没有提供类似于&lt;code> ipmi&lt;/code> 管理功能，这些服务器自动启动依赖于主板自带的 &lt;code>网络唤醒&lt;/code> 功能，如果服务器未正常关机时 (卡在关机界面)，第二天早上通过网络唤醒时是无法正常打开服务器的，需要管理人员的介入管理强制关机。这篇文档主要是介绍如何优化服务器的关机时间长，服务器关机卡死问题。&lt;/p></description></item><item><title>Shell 脚本编程完整实战指南</title><link>https://blog.treesir.pub/posts/shell-docs/</link><pubDate>Fri, 02 Dec 2022 15:12:34 +0800</pubDate><author>yangzun@treesir.pub (Zayn)</author><guid>https://blog.treesir.pub/posts/shell-docs/</guid><description>&lt;p>Shell 是 Linux/Unix 系统的核心组件，既是命令行解释器，也是强大的脚本编程语言。掌握 Shell 编程对于系统管理员、运维工程师和开发者来说至关重要。本指南将从基础概念开始，逐步深入到高级应用，帮助您全面掌握 Shell 的使用技巧。&lt;/p>
&lt;h2 class="relative group">Shell 基础概念
&lt;div id="shell-基础概念" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#shell-%e5%9f%ba%e7%a1%80%e6%a6%82%e5%bf%b5" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h2>
&lt;h3 class="relative group">什么是 Shell
&lt;div id="什么是-shell" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#%e4%bb%80%e4%b9%88%e6%98%af-shell" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h3>
&lt;p>Shell 是用户与 Linux 内核交互的接口，它具有以下特点：&lt;/p></description></item><item><title>GitLab Pre-receive 钩子的配置与使用指南</title><link>https://blog.treesir.pub/posts/gitlab-pre-receive-webhook/</link><pubDate>Mon, 12 Apr 2021 17:25:58 +0800</pubDate><author>yangzun@treesir.pub (Zayn)</author><guid>https://blog.treesir.pub/posts/gitlab-pre-receive-webhook/</guid><description>&lt;h2 class="relative group">环境说明
&lt;div id="环境说明" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#%e7%8e%af%e5%a2%83%e8%af%b4%e6%98%8e" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h2>
&lt;h2 class="relative group">版本信息
&lt;div id="版本信息" class="anchor">&lt;/div>
&lt;span
class="absolute top-0 w-6 transition-opacity opacity-0 ltr:-left-6 rtl:-right-6 not-prose group-hover:opacity-100">
&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700 !no-underline" href="#%e7%89%88%e6%9c%ac%e4%bf%a1%e6%81%af" aria-label="锚点">#&lt;/a>
&lt;/span>
&lt;/h2>
&lt;ul>
&lt;li>GitLab 版本：13.10.2&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>如需了解 GitLab 服务器安装方法，请参考 &lt;a
href="https://www.treesir.pub/post/gitlab-deploy/"
target="_blank"
>安装文档&lt;/a>。本文将详细介绍如何在 GitLab 中添加和配置 &lt;code>pre-receive&lt;/code> 钩子，并演示如何对 &lt;code>git push&lt;/code> 操作进行限制。&lt;/p></description></item></channel></rss>