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:

startup applications

Add

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like