Ask Your Question

Auto shutdown?

asked 2015-11-08 10:12:45 -0500

sjaak gravatar image


I run Fedora 21 Workstation, and use it for a NAS server. it works perfect! The only problem i have is that you dont have a function to auto shutdown. i know it is possible to run a .desktop file or another file type. but i dont know how to set it up.

What i need is when the system boot, not login, the command:

"shutdown -h 22:00" runs

How should i set this up??? Sorry for my bad English :(

Greets, Sjaak

edit retag flag offensive close merge delete

Comments maybe add a systemd timer, I am used to using atd or crond, so the below might be wrong. [Unit] Description=Nightly Poweroff [Timer] OnCalendar= --* 22:00:00

spollei gravatar imagespollei ( 2015-11-08 11:22:04 -0500 )edit Probably should add : [Install] and remember to add this config file named something like nightly_off.timer in /etc/systemd/system/ or /usr/lib/systemd/system .

spollei gravatar imagespollei ( 2015-11-08 11:25:16 -0500 )edit

Thank you for your anwser

sjaak gravatar imagesjaak ( 2015-11-16 14:35:45 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-11-17 10:37:52 -0500

sjaak gravatar image

updated 2015-11-19 09:33:43 -0500

florian gravatar image

This was what i did: sudo su - crontab -e then edit the file with the follow text:

0 22 * * * /sbin/shutdown -h now

Then pressed "Esc", pressed ":" and typed "wq" to save and close the file after that i checked it with crontab -l and saw my cronjob in that list. and at 22:00 the computer started shutting down

edit flag offensive delete link more


Glad it works! BTW, there is no need to enter a root terminal first (sudo su), you can just run any command with root permissions by typing sudo <command>, in your case sudo crontab -e.

florian gravatar imageflorian ( 2015-11-19 09:35:48 -0500 )edit

answered 2015-11-08 20:04:06 -0500

florian gravatar image

updated 2015-11-12 08:09:42 -0500


This is how I would do it (That does not mean that is the most elegant solution but it should work. Very likely that systemd.timer method is better/recommended). If you want it quick and dirty, take this:

Use a little shell script in /etc/rc.d/rc.local which will be executed every time you start your PC. Use gedit to create the script: gedit /etc/rc.d/rc.local Then paste something like:

shutdown -h 22:00

Then make rc.local excutable: chmod +x /etc/rc.d/rc.local.

You should be good to go...

edit flag offensive delete link more


i tested both comments, but both of them doesnt work for me. i think i did something wrong, but i dont know what. some more tips??? or should i send some screenshots??

sjaak gravatar imagesjaak ( 2015-11-10 02:57:36 -0500 )edit

Yea, sorry. I guess, I was wrong with the path of rc.local. It should be located in /etc/rc.d/ (and not/etc/rc.local). Try it again by moving rc.local file to /etc/rc.d/ and make sure it is executable (chmod +x /etc/rc.d/rc.local). I am going to edit my answer now.

florian gravatar imageflorian ( 2015-11-10 13:29:17 -0500 )edit

I guess, you also have to start the service: sudo systemctl start rc-local.service.

florian gravatar imageflorian ( 2015-11-10 13:34:07 -0500 )edit

answered 2015-11-12 07:16:28 -0500

sjaak gravatar image

updated 2015-11-12 07:52:52 -0500

It doesnt work. here are some screenshots:

at screenshot 1 i typed:

 gedit /etc/rc.d/rc.local

and make the file:

shutdown -h 22:00

at screenshot 2 i typed in:

chmod +x /etc/rc.d/rc.local

and at screenshot 3 i typed:

 sudo systemctl start rc-local.service

and then got the error massage

edit flag offensive delete link more


OK, first of all, apologies once again. I had a typo in the first line of the bash script (forgot the !). I has to be: #!/bin/bash.

I saw in your screenshot that you used a root terminal. In that case sudo in front of any command is obsolete. No clue yet, why it fails but please first correct rc.local file, and try again, and then post the output of systemctl status rc-local.service. No need for a screenshot. Just mark the text in your terminal, copy it (CTRL+SHIFT+C) and paste it here. Thanks.

florian gravatar imageflorian ( 2015-11-12 08:17:03 -0500 )edit

Try enabling the service first, before you start it: systemctl enable rc-local.service

florian gravatar imageflorian ( 2015-11-12 19:52:30 -0500 )edit

Unfortunately, I personally don't. Looks like the step with enable rc-local is useless as rc-local is a static service. I would suggest opening a new question asking How to start rc-local.service on Fedora 22.

florian gravatar imageflorian ( 2015-11-16 11:15:42 -0500 )edit

Thanks for your anwsers and time. i fixed the problem, i now use a cronjob. greets Sjaak

sjaak gravatar imagesjaak ( 2015-11-16 14:35:21 -0500 )edit

Feel free to write an answer to your own question describing how are doing it using cron, That way other may benefit.

florian gravatar imageflorian ( 2015-11-16 15:02:08 -0500 )edit

Question Tools



Asked: 2015-11-08 09:42:43 -0500

Seen: 1,290 times

Last updated: Nov 19 '15