实际上,我不太确定是否应该使用 Shell 脚本,或者是否已经有一些方法。但是无论我们使用什么方法,我都希望服务一直运行。
比方说,iptables
作为一个例子。然后 ..
iptables
服务stopped
或(换句话说)没有运行,我希望它是started
(或restarted
)..自动无论何时停止(或不运行)。(也许我可以给出一个公平的频率来检查,如果进行实时检查是问题。所以可以说,每 5 分钟一次)
我能想到的唯一方法是在 Cron Tab 中使用 Shell 脚本。
谢谢!
在我的 CentOS 中,我需要dhclient -v
在每次启动/重新启动服务器时运行命令。请问如何永久生效?
我试图只获取curl
命令输出的第一行。(对不起,如果这令人困惑)
比方说,例如,我简单地运行:
# curl http://localhost
<!-- This is the hidden line i want to grab. -->
<!DOCTYPE html>
<html>
<head>
..
..
Run Code Online (Sandbox Code Playgroud)
如果我想要这里输出的第一行,该怎么办,即:
<!-- This is the hidden line i want to grab. -->
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这样的事情,但还没有运气:
# curl http://localhost | head -n 1
# curl http://localhost | sed -n '1!p'
Run Code Online (Sandbox Code Playgroud)
.. 等所有给我垃圾输出,像这样:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- …
Run Code Online (Sandbox Code Playgroud)