- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是我的 previous question 的后续问题
所以我有这个 shellscript 来监视 Gentoo 上的 nginx 日志文件,问题是日志文件在特定文件大小或一段时间后被重命名和 gzip 压缩,shellscript 仍在查找原始文件描述符(或 inode? ), 新文件内容不会显示。
我的问题是,如何连接到自动 gzip 脚本以重新启动我的日志文件监控脚本以监控新日志文件?
顺便说一句,请不要使用 cronjob 或计时器来完成它。我想要我的监控脚本的近乎实时的响应。
最佳答案
为tail
使用-F
标志而不是-f
标志| (或者 --follow=name
也可以工作,尽管它只能在 Linux 上工作,而 -F
也可以在 BSD 和 Mac OS X 上工作):
--retry
keep trying to open a file even if it is inaccessible when tail
starts or if it becomes inaccessible later -- useful only with
-f
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and --fol-
low=descriptor are equivalent
-F same as --follow=name --retry
With --follow (-f), tail defaults to following the file descriptor,
which means that even if a tail’ed file is renamed, tail will continue
to track its end. This default behavior is not desirable when you
really want to track the actual name of the file, not the file descrip-
tor (e.g., log rotation). Use --follow=name in that case. That causes
tail to track the named file by reopening it periodically to see if it
has been removed and recreated by some other program.
关于linux - 用于监视 Gentoo 上的 nginx 日志文件的 shellscript 在日志文件被 gzip 后过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4405701/
这个问题在这里已经有了答案: What does the $# construct mean in bash? [duplicate] (3 个答案) 关闭 7 年前。 我有一个包含以下几行的 sh
如何在shell脚本中将字符串拆分为数组? 我试过 IFS='delimiter'它适用于循环 (for, while)但我需要一个来自该字符串的数组。 如何从字符串创建数组? 谢谢! 最佳答案 st
我的 shellscript 不工作: #!/bin/bash LIST="$(ls -rt *.log.*)" for i in "$LIST"; do echo $i mysql --user=
这个问题在这里已经有了答案: Why would a correct shell script give a wrapped/truncated/corrupted error message? [
我有一个列表,例如: 10、汽车轮胎 8、汽车轮胎 4、轮子 18、 pry 棍 5、插孔 5、插孔 8、 jack 斯 第一个数字是数量,第二个数字是商品名称。我需要获取此列表,以便它只显示每个项目
我正在尝试检查文件是否超过 5 分钟,如果是这种情况,我想调用另一个 shell 脚本,它会向我发送邮件。 检查文件.sh: #!/bin/sh if [$(( (`date +%s` - `stat
我有名为“images123.jpg”、“images456.jpg”等的文件 我想将这些文件 mv 到 testfolder 文件夹中,并相应地将它们重命名为“123.jpg”、“456.jpg”等
我正在尝试编写一个简单的 shell 脚本,如果有第一个参数则打印出第一个参数,如果没有则打印“无”。该脚本名为 test.sh if [$1 = ""] then e
我正在使用此命令将文件导入我的服务器: scp zumodo@shold:/test/test/test/server.py /test/test/test/test.py~/; 如果新导入的文件 t
我正在尝试使用正则表达式编写一个 bashscript 检查来区分以下文件。我试图在 if 语句中选择 DRLIC_INFO_20170912.out 而不是 DRLIC_INFO_20170912_
我想通过 shell 脚本对系统间缓存执行一些命令。我知道的一种解决方案是制作配置文件,但问题是我不知道如何通过 shell 脚本使用配置文件。有没有其他解决方案... 例如我必须在缓存上运行的是 c
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
我正在尝试在 bash 中创建我的第一个 shell 脚本。我已经创建了代码,并设法将脚本保存在我的主目录中,但它无法运行。首先,我尝试从主目录运行它:./testscript.sh,并以“权限被拒绝
我一直试图让我的脚本在每天早上 6:01 运行。 脚本获取数据并将其输出到如下所示的 .xml 文件。 #!/bin/sh tv_grab_se_swedb --days 1 --quiet --ou
我正在尝试通过像这样非常简单的 bash 脚本来激活我的 pyenv-virtualenv 环境。 set -e pyenv activate myenv 但我无法激活我的环境并出现以下错误: Fai
我正在尝试制作一个执行以下操作的 shell 脚本: 启动程序 x 在 x 运行时执行一些命令,例如: echo "blabla" >> ~/blabla.txt 执行这些命令后,程序 x 应该在前台
这个问题已经有答案了: Propagate all arguments in a Bash shell script (12 个回答) 已关闭 4 年前。 从一个shell脚本中,我想调用一个调用ja
现在我对 shell 脚本和 Linux 本身还很陌生,我很困惑为什么这不起作用。解释和答案会很有帮助,因为我真的很想学习这个。无论如何,这是我的代码: #!/bin/bash
我们想从 XML 文件中读取 XML 属性。文件内容示例如下: 我们想使用 shell 脚本读取属性“abc”的值(即 15)。 请建议 shell 命令来实现这一点。 最佳答案 您可
您可以在下面看到我尝试使用 shell 脚本更改 umask,并被对话框覆盖。 基本上,我将输入框的输入读取到一个变量中,然后使用它通过 umask 执行它以最终更改它。但是.. 它不起作用.. 我取
我是一名优秀的程序员,十分优秀!