2006/08/12

HOWTO: Perform a scheduled shutdown without installing additional software

The easiest way of performing a scheduled shutdown of a Linux computer, that came to my mind, was executing something like this:

  sleep 3600 && poweroff

However, this couldn't work, since root privileges are necessary to run poweroff command. So you have to use:

  sleep 3600 && sudo poweroff

But this will cause the computer to wait for 1 hour (3600 seconds) and then prompt for the root password. And what we are trying to avoid is sitting in front of the computer at that time.

But there is a very simple solution:
  1. Type sudo visudo to edit the /etc/sudoers file.
  2. Add the following line:
    your_username ALL= NOPASSWD: /sbin/poweroff

Now you can execute sudo poweroff without typing the password.

No comments:

Post a Comment