0

I am sending a reboot and shutdown command to a Free BSD computer. However I want to check that will that computer be shutdown or reboot really (I send this command from a reboot computer and I want to be sure that if my command will run) I don't want to ping or etc, is there any command to learn it?

EDIT 1: I think that I should be more clear about my question. From my java server application I send one of that commands:

reboot // or any other command to reboot
shutdown -p now

I call that commands at another Java program at client side. Let's think reboot scenario. After I send reboot command from server side, I want to check will client reboot or not. If I ping it after I send that reboot command, client Free BSD machine may be still alive. However it can reboot after a time later. On the other hand After I send reboot command, something may happen bad and that communication breaks and client may not receive that reboot command.

How can I handle this issue(I don't want solution with Java side) Does Free BSD keeps that reboot or shutdown signals at somewhere (to know that machine will be reboot or shutdown) and can I query that will machine scheduled itself to reboot or shutdown immediately?

EDIT 2: Server sends one of that commands to client(my server and client coded at Java ) If I ping after I send i.e. shutdown command, maybe machine will shutdown but still alive(it will shutdown maybe after 2 seconds later.) If I can query my client did it received a shutdown(or reboot) command even it is still alive I will accept that OK it will shutdown(or reboot) If I can not get an answer to my query to client it means that it is not alive, so I will accept that it is shutted down(or rebooting). How can I query my machine like that?

2
  • 1
    I am not sure I understand the question. You are sending a reboot command to the FreeBSD server and a shutdown command (either with shutdown to single user mode, reboot, or power off options). And you wonder which of these will happen?
    – Hennes
    Commented Aug 2, 2012 at 17:51
  • @Hennes can you check my edit?
    – kamaci
    Commented Aug 2, 2012 at 18:56

4 Answers 4

3

Unless you are on an old x86 system with a buggy BIOS or a non-x86 system with some type of buggy firmware, reboot should always actually reboot, assuming you don't have an issue with devices hanging or buggy device drivers/kernel modules.

poweroff is slightly different. This requires ACPI support on x86 machines. However, it should only be an issue on older x86 hardware. I have a dual 533Mhz Pentium-II motherboard that has an issue whereby if ACPI is enabled, only 1 CPU is visible. Disabling ACPI allows both CPUs to be used. However, since ACPI is not enabled, poweroff will not actually power off the system, but merely halt it. I believe this system to be from the mid to late 90's. I can't imagine it being an issue on anything fairly recent.

On non-x86 machines it probably won't power a system off unless you have specific kernel support for that CPU or board.

And of course if your currently running kernel does not have ACPI support your kernel cannot likely shutdown the machine.

So probably the best you can do is check for ACPI support.

1
  • can you check my edit?
    – kamaci
    Commented Aug 2, 2012 at 18:53
0

Besides pinging, you could run a daemon (like sshd - which I assume you're doing, since you are connecting remotely) on the machine and, if it fails to connect, the machine is (presumably) off.

1
  • can you check my edit?
    – kamaci
    Commented Aug 2, 2012 at 18:54
0

OK. I now understand it as follows:

A java application at a client sends either the command reboot or shutdown -p now. Then the connection might be broken, and you wonder if the command still completes.

The answer for shutdown is easy: Yes, it completes. I often used shutdown with a time a few hours in advance, then logged off and the server nicely shut down at the specified time.

The same should happen with shutdown -r, which reboots.

I do not know what happens with /sbin/reboot. I never used it. I suspect that it will still complete, but I never tested that.

5
  • Server sends one of that commands to client(my server and client coded at Java ) If I ping after I send i.e. shutdown command, maybe machine will shutdown but still alive(it will shutdown maybe after 2 seconds later.) If I can query my client did it received a shutdown(or reboot) command even it is still alive I will accept that OK it will shutdown(or reboot) If I can not get an answer to my query to client it means that it is not alive, so I will accept that it is shutted(or rebooting). How can I query my machine like that?
    – kamaci
    Commented Aug 2, 2012 at 19:22
  • Try this on a test machine: shutdown -p +60 Testing. This should shut the server down in 60 minutes. Now try it again. If memory serves you get a message that shutdown is already running (thus confirming that the previous command was received).
    – Hennes
    Commented Aug 2, 2012 at 19:45
  • How can I learn memory serves me a message that it is running shutdown message?
    – kamaci
    Commented Aug 3, 2012 at 6:22
  • "If my memory serves me" is an expression means "If I remember this correctly". - As to detecting it: Log into a computer and try the shutdown -p +60 Testing command twice. Look at the difference in the output of the first and second command.
    – Hennes
    Commented Aug 3, 2012 at 10:57
  • Thanks for explanation for that expression :) Can you give me the output because I am running a win7 computer and I will test it on a FreeBSD later?
    – kamaci
    Commented Aug 3, 2012 at 11:11
0

At free bsd it makes a file /var/run/nologin. I check it to understand if one of that signals is received or not.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .