4.24. Disabling VPS at a specific time

For technical work, sometimes it is necessary to turn off the server at a certain time. The shutdown process can be automated using the at service.

  1. Connect to the server via SSH.
  2. Check if the system time set on the server is correct:
    TZ='Europe/Kyiv' date

    If the time is set incorrectly, correct it:

    ntpdate ptbtime1.ptb.de && hwclock -w

    Note The package must be installed on the server to run the command ntpdate or netdate.

  3. Check if the at service is running in the process list (displayed as atd):
    ps ax | grep atd

    If the service is not running, start it:

    /etc/init.d/atd start

    Note The package must be installed on the server to run the command at.

  4. Create a task with the command to shut down the server at the right time on the right day, for example, to shut down the server on December 8, 2022 at 9:15 am, the task creation command looks like this:
    echo "/sbin/shutdown -h now"  |  at  09:15  08.12.2022
  5. Check if the created task is in the list of tasks:
    atq

When the time specified in the task arrives, the shutdown command will be automatically executed on the server. You can turn on the server after such a shutdown using forced reboot.

Content