我如何知道系统是否已开机?

发布于 2024-07-07 20:49:24 字数 367 浏览 6 评论 0原文

我正在编写一个通过网络启动系统的脚本。 然后我需要在另一台主机上运行一些命令。 如何知道系统是否已开机?

我的编程语言是Perl,目标主机是RHEL5。

是否有任何内核中断或网络启动信息表明系统已上电且操作系统已加载?

[在不同的情况下]我还想知道以防万一我是否只是手动打开我的机器。 确切地说什么时候已经通电了。 操作系统何时应该完全启动以进行网络相关操作,例如在那里执行网络命令。 如果系统使用 DHCP,远程系统将如何搜索这台机器[我猜这可以通过 mac 地址实现。 但如果我错了]。

如果我遗漏了任何信息,请随时询问我。 如果您有任何让任务变得更容易的建议,请提出:)

谢谢 伊姆金

I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on?

My programming language is Perl and the target host is RHEL5.

Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded?

[In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and when is the OS is supposed to have booted completely for a network related operation such as executing a network command there. What if the system is on DHCP how would a remote system then search for this machine [i guess it is possible via mac address. but if i am wrong ].

If I have missed out any info please feel free to ask me. If you have any suggestions to make the task easier please surface them :)

thanx
imkin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你是我的挚爱i 2024-07-14 20:49:24

好吧,我想说的是,当系统可以执行您对其提出的请求时,系统就会启动。 即 sshd 守护进程正在运行。 这已经足以满足您的目的(我假设 - 替换您真正需要的任何守护进程)。

因此,我会发送开机信号,并每隔 15-30 秒检查一次,看看是否可以连接。 如果我在该机器的合理时间内(2 分钟或 5 分钟或其他)未能连接,那么我会向 IT 支持团队发送警报。 好吧,我会先将其发送给自己,只有当我调查了一些故障并发现它们都是合法的后,我才会开始将其直接发送给 IT。

DHCP 是一个不同的问题。 您必须开始学习广播,或者让该机器上的守护进程在启动期间“回拨”以注册其当前的 IP 地址。 每次 DHCP 更新更改其 IP 地址时,它都必须“回拨”。 这显然更加复杂。 如果可能的话,尽量避免在此类服务器计算机上使用 DHCP。

Well, I'd say the system is booted when it can perform the request you've made of it. That is, the sshd daemon is running. That's booted sufficiently for your purposes (I assume - substitute for whatever daemon you really need).

So, I'd send the power-on signal, and check back every 15-30 seconds to see if I could connect. If I've failed to connect within whatever is a reasonable time for that machine (2 minutes or 5 minutes or whatever), then I'd send an alert to the IT support team. Well, I'd send it to myself first, and only once I've investigated a few failures or so and found them to all be legitimate would I start sending it directly to IT.

DHCP is kind of a different question. You'd have to start learning about broadcasting, or having a daemon on that machine "call home" during boot to register its current IP address. And it would have to "call home" every time a DHCP renewal changed its IP address. This is decidedly more convoluted. Try to avoid DHCP on such server machines if at all possible.

恬淡成诗 2024-07-14 20:49:24

在重新启动的计算机上,您可以使用特殊的 @reboot 断言在 crontab 中安装脚本(请参阅 man 5 crontab)。 该脚本可以向另一台计算机发送某种通知,通知它现在已启动。

On the rebooting machine you can install a script in your crontab with the special @reboot assertion (see man 5 crontab). That script could send a notification of some kind to the other machine, notifying it that it's up now.

妳是的陽光 2024-07-14 20:49:24

我认为检查 sshd 听起来是一个好方法。

至于 DHCP 问题:如果另一台计算机位于同一子网中,您可以使用 Net::ARP

I think checking for sshd sounds like a good approach.

As for the DHCP problem: if the other computer is on the same subnet you can look it up by MAC address using Net::ARP.

萤火眠眠 2024-07-14 20:49:24

如何向远程计算机添加一个在启动时运行的脚本,让它告诉您何时准备就绪。

How about adding a script to the remote machine which gets run on startup to have it tell you when it is ready.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文