Results 1 to 5 of 5

Thread: Shutdown server every night

  1. #1
    Join Date
    Oct 2007
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 9.10 Karmic Koala

    Shutdown server every night

    Hi,

    I have made some homeserver thingy, it's just some crappy old computer which i only use as fileserver and {sometimes} as webserver.

    The pretty part: it's all working

    The not so pretty part: I only use it when the sun shines, so this old power-consuming is using power and power every night for no purpose...

    I know the command for shutting down at e.g. 23:00 is "sudo shutdown 23:00". But how can i execute this command (as root), every time i start the computer?

    btw, it's server 7.10

  2. #2
    Join Date
    Jan 2006
    Location
    United Kingdom
    Beans
    2,787
    Distro
    Kubuntu 6.06 Dapper

    Re: Shutdown server every night

    There are many ways to skin this cat, but as an alternative to what you were asking it might prove more elegant to let cron turn the machine off according to schedule. Specifically, put the following into a file in /etc/cron.d/

    Code:
    # Cron job to turn the machine off at 2300hrs every night
    
    # Send any error output to root for fault diagnosis
    # (STDOUT will be redirected to /dev/null)
    MAILTO=root
    
    # Actual schedule/command
    # Format: Min Hr DayofMth Mth DayofWk User Command
    00 23 * * * root shutdown > /dev/null
    One advantage of doing it this way is that you could customise the schedule if, say, you wanted it to remain on later at the weekends etc.

    Mathew
    Last edited by MJN; June 18th, 2008 at 09:57 PM.
    www.NewtonNet.co.uk - Now supporting IPv6!

    ~ Please don't use PM's to request assistance - post your query on the forum and share the discussion - if you've got a problem chances are you won't be the only one! ~

  3. #3
    Join Date
    Oct 2007
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Shutdown server every night

    thanks

    it looks like it's working

    and if i understand it right, i can just make these kind of tasks (any task) in /etc/cron.d/ just like some sort of task-manager?

    thanks again

  4. #4
    Join Date
    Jan 2006
    Location
    United Kingdom
    Beans
    2,787
    Distro
    Kubuntu 6.06 Dapper

    Re: Shutdown server every night

    That's right. I would recommend learning a little about cron as it is incredibly useful.

    There are many other ways rolling cron to make it do what you want, including have personal 'crontabs' for each user, using the scheduled system cron jobs in /etc/cron.[hourly|daily|weekly]/ etc - as the administrator of my server I tend to use /etc/cron.d to allow me to have the granular control I require whilst also keeping my cron jobs all in one place.

    Mathew
    www.NewtonNet.co.uk - Now supporting IPv6!

    ~ Please don't use PM's to request assistance - post your query on the forum and share the discussion - if you've got a problem chances are you won't be the only one! ~

  5. #5
    Join Date
    Oct 2007
    Location
    Netherlands
    Beans
    Hidden!
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Shutdown server every night

    ok, thanks for the advice!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •