(Solved)Auto shutdown at 10:30PM daily

Forum rules
Before you post please read how to get help
opale7000
Level 2
Level 2
Posts: 77
Joined: Fri May 19, 2017 9:04 am

(Solved)Auto shutdown at 10:30PM daily

Postby opale7000 » Mon Jun 12, 2017 11:45 am

Hello All

What would be a way for me to auto shutdown my computer everyday at 10:30PM :?:

Linux mint 18.1 Cinnamon

8)
Last edited by opale7000 on Fri Jun 16, 2017 9:40 pm, edited 1 time in total.

now3by
Level 1
Level 1
Posts: 43
Joined: Mon Jan 23, 2017 1:56 pm

Re: Auto shutdown at 10:30PM daily

Postby now3by » Mon Jun 12, 2017 1:05 pm

crontab is your friend:

sudo crontab -e

and add this lines:

Code: Select all

# shutdown every night at 22:30
30 22    * * *    /sbin/shutdown -h now
Linux...

acerimusdux
Level 4
Level 4
Posts: 301
Joined: Sat Dec 26, 2009 3:36 pm

Re: Auto shutdown at 10:30PM daily

Postby acerimusdux » Mon Jun 12, 2017 1:09 pm

This is one of those that might have more than one good answer.

But I think the typical unix way would be to run a cron job. Which you can do by editing your crontab file. The following for example would add the needed line to /etc/crontab:

Code: Select all

sudo bash -c 'echo "30 22   * * *   root    /sbin/shutdown -h now" >> /etc/crontab'


The line actually added to the file is everything between the " quotes. You could also just open an editor as root and add this line. The 30 22 is just minutes, hours (in 24 hr format), so means 10:30 PM. The three stars after that indicate to run every day, every month, every day of the week. Then you have the user to run the command, and the command to be run.

edit: ah, now3by beat me to it. And using crontab -e looks like the easiest way to edit the file.
Last edited by acerimusdux on Mon Jun 12, 2017 1:14 pm, edited 1 time in total.

opale7000
Level 2
Level 2
Posts: 77
Joined: Fri May 19, 2017 9:04 am

Re: Auto shutdown at 10:30PM daily

Postby opale7000 » Mon Jun 12, 2017 1:13 pm

Agreed that there numerous ways to shut down and will try the following for tonight

Code: Select all

# m h  dom mon dow   command

30 22 * * * sudo poweroff



And if no go will try your other options. Thanks guys

acerimusdux
Level 4
Level 4
Posts: 301
Joined: Sat Dec 26, 2009 3:36 pm

Re: Auto shutdown at 10:30PM daily

Postby acerimusdux » Mon Jun 12, 2017 1:24 pm

Don't think you want to run sudo from crontab. If you use roots crontab (in /etc/crontab, accessed by sudo crontab -e) it will already run with root permissions. And actually, you don't need to be root to run shutdown in Mint. So you could just do crontab -e, and add the poweroff -h command there.

opale7000
Level 2
Level 2
Posts: 77
Joined: Fri May 19, 2017 9:04 am

Re: Auto shutdown at 10:30PM daily

Postby opale7000 » Mon Jun 12, 2017 2:37 pm

acerimusdux wrote:Don't think you want to run sudo from crontab. If you use roots crontab (in /etc/crontab, accessed by sudo crontab -e) it will already run with root permissions. And actually, you don't need to be root to run shutdown in Mint. So you could just do crontab -e, and add the poweroff -h command there.


Much appreciated. Will revise. Thanks

opale7000
Level 2
Level 2
Posts: 77
Joined: Fri May 19, 2017 9:04 am

Re: Auto shutdown at 10:30PM daily

Postby opale7000 » Fri Jun 16, 2017 9:39 pm

Only gsShutdown app does the job. All crontab commands do not work for me.


Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 1 guest