Automatic Shutdown After 2 Hours on Every Boot

Automatic Shutdown After 2 Hours on Every Boot

I am using both Ubuntu and Lubuntu 16.04 and this question is regarding both of them.

I want my computer to always shut down 2 hours after it was turned on, i tried to use these instructions that I found to run a timed shutdown on startup but it does not work.

How can I do that?

2

1 Answer

1.Edit sudoers (you must be root):

gedit /etc/sudoers

At the end add following:

yourusername ALL=(ALL) NOPASSWD: /sbin/shutdown

and save.

2.Crete .sh script:

gedit myscript.sh

add following there:

#!/bin/sh
sudo shutdown -P +120 # shut down after 120 minutes

3.run "startup applications" tool you just need write it in search box. And press Add button:

Write there your .sh script name and path to it. Press add there too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.