Fri Jun 9 11:59:07 +07 2023

Another way to shutdown all the systems

When a power interruption is planed, it is easy to set-up a programmed shutdown of the machines, using a scheduled shutdown.

The machines should be stopped in the following order that will conform with the interdependancies between the services:

First, stop the machines that no other service depends on:
The machines are ufo, mail, firewall, router, bazooka, active, amanda, database, door, guppy, gourami, puffer and exam.
Second, stop the file server:
The machine is banyan.
Third, stop DNS and authentication:
The machines are dns and ldap.
Fourth, stop the syslog server:
The machine is sysl.
Fifth, stop the virtual servers:
The machines are virtual, virtual2, virtual3, virtual4, virtual5, teal1 and teal2.

There should be approximately 10 minutes between each steps, so if the first phase should stop on Sunday at 7:00, the second phase will be on Sunday at 7:10, etc. and the last phase on Sunday at 7:40.

Add a crontab entry line in root user on each machine, this will allow to schedule the shutdown a long time in advance.

The date and time for crontab are as follow:
minute hour day-of-the-month month day-of-the-week
where the minutes are between 0—59, the hour 0—23 and Sunday is represented by either 0 or 7.

On FreeBSD the command is:
0 7 * * 0 /sbin/shutdown -p now
On Linux the command is:
0 7 * * 0 /sbin/shutdown -h now
On ESXi the procedure is:
Note: The time on ESXi servers is UTC, so the clock is 7 hours back: to stop the machine a 7:40, you must enter a time of 0:40. If you plan to stop the server around midnight, you must enter the time as 17:00.
  1. Go to /var/spool/cron/crontab
  2. Change the file root to writable chmod 600 root
  3. Edit the file root and add the line 40 0 * * 0 /bin/poweroff
  4. Find the crond process ps -c|grep crond
  5. And kill it
  6. Restart the crond process /usr/lib/vmware/busybox/bin/busybox crond

After the system has bee restarted, you must remove or comment out the line in the crontab (except on ESXi servers and firewall); else the system will shutdown on the next Sunday.

Amanda starts a backup run every night at 00:05, it is better to halt the machine around 23:50, before a run, than just when a new run has started for example at 00:15.

Do not use the -p option with the door machine because it restarts automatically as soon as it is powered down, it is better to keep the system halted but still with power on.


Posted by Olivier | Permanent link | File under: administration, firewall, vmware, freebsd, router