Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Shut Down unRaid at specific time

Featured Replies

Is there any way to schedule shutdown of unRaid?  Ideally, I'd like to be able to wake it up at a certain time too, but I guess thats more difficult  ;)

 

e.g.

Shutdown @ 11:30pm

Wakeup @ 6am

 

Will save some valuable power for me as unRaid is not used between those times.

Wakeup can occur via 2 possible methods.

 

1. WAKE on LAN from an always on Server (I've used this with success).

2. WAKE Up via BIOS option -  There are usually BIOS options that allow a machine to be woken up on a daily basis.

 

As far as powerdown.

 

You can use my powerdown script found elsewhere in the forum and in the wiki.

All you need to do is create a cron job to run the power down script at the selected time

Let us know if you need assistance with that.

  • Author

Thanks for the reply.

 

Yep, I could do with some help setting up the cron job.  I found your powerdown script which seems to bind powerdown to CTRL_ALT_DEL.. how do I modify that to just powerdown?

 

From a quick google I found i need to use crontab, and create an entry for a specific time to run the script. Can you give me an example on how to do this?

What time are you looking to power down?

 

  • Author

say 11pm.

 

I found the format of entering a job into crontab, but i'm unsure how to enter that each time unraid boots..?

say 11pm.

 

I found the format of entering a job into crontab, but i'm unsure how to enter that each time unraid boots..?

First, to power down cleanly, the array must be stopped.  If you have installed the alternate powerdown command as described earlier you will be fine as it stops the array before continuing. If not, your array will do a parity check when next powered up.

 

You must put all the "cron" entries in a single file (including your new powerdown command) and then use the crontab command to add it to the scheduler.

 

The following commands in your "go" script might do it.

crontab -l >/tmp/crontab

echo "# powerdown at 11:PM every day:" >>/tmp/crontab

echo "0 23 * * * /sbin/powerdown 1> /dev/null" >>/tmp/crontab

crontab /tmp/crontab

 

You can view the existing entries (and newly added ones) in the crontab file with

crontab -l

 

As an alternative to what I've described in the prior paragraph or two, since you want to power down every day, it might be a lot easier use the "at" command instead of using the "crontab" command. 

You can add a  single line to the "go" script like the following:

echo "/sbin/powerdown" | at 23:00

 

Have fun...

 

Joe L.

Perhaps we should add some housekeeping to this as well. Things like reiserfs check and that kinda goodness?

 

This way you could wake up in the morning power on your box and look at the previous nights health check.

 

It might also be a good idea to make this "shutdown sometime after midnight when the shares havent been accessed for xx hours.". This way you can use 2 to shut it down at 2am but if you use the box until 2:15 am it will shut down itself at 4.15 am. Otherwise we basically have made a box that will not have a way to power up for a few hours a day i.e. it will boot up and you will be racing to change the config before it powers itself down.

 

Here is now to add/re-add/update the /sbin/powerdown command in root's crontable.

Adjust the line between the cat and EOF to what ever is needed.

You can add other calls in there, but for now keep in mind the first grep only removes /sbin/powerdown.

 

The reason is so you can re-adjust the time and rerun this script to update the /sbin/powerdown line.

 

It's set for 11pm now.

 

It requires my powerdown script to be placed in /sbin/powerdown and expects it to be executable.

 

I call this script powerdown_daily.

Put it in /boot/custom/bin as powerdown_daily

You can then call it from your go script with

 

fromdos < /boot/custom/bin/powerdown_daily > /tmp/powerdown_daily

chmod u+x /tmp/powerdown_daily

/tmp/powerdown_daily

rm /tmp/powerdown_daily

 

or you can just put the lines below directly in your go script.

It's small enough.

 

 

#!/bin/bash
# Set a daily power down in root's crontable.
# This can be run multiple times
# if you need to adust the time.
# i.e. it removes the powerdown calls
# on extract, so it can be re-added later.

# Extract root's crontable. Removing any prior powerdown calls. 
crontab -u root -l | grep -v /sbin/powerdown > /tmp/crontab.root

# Append new entries to root's crontable
cat <<-EOF >> /tmp/crontab.root
# Daily Automatic /sbin/powerdown
00 23 * * * /sbin/powerdown
EOF

# Update root's crontable.
crontab /tmp/crontab.root -u root

rm /tmp/crontab.root

Perhaps we should add some housekeeping to this as well. Things like reiserfs check and that kinda goodness?

I would not want to make the shutdown any more complicated then it is already.

 

I think the right way to do this is how windows does whereby you schedule a fsck upon restart.

redhat has this with a flag placed in the root directory...

I had proposed an empty flag to do all, and if it had lines in it, to do the filesystems that exist in the file.

We;ll see where that goes.

 

 

It might also be a good idea to make this "shutdown sometime after midnight when the shares havent been accessed for xx hours.".

 

How do you know the shares have not been accessed for a period of time?

It's one thing to set a drive timer, which is internal to the drive.

How do you propose monitoring the environment to detect lack of activity?

  • 4 weeks later...
  • Author

Hi all.  Thanks for the help so far, I now have the tower shutting down at 11pm each night  :)

 

Next problem is I dont seem to be able to wake it up without pressing the power button.  Sending a magic packet does not wake the machine up, even though ethtool seems to report that the nic is enabled for WOL.  Is this something unraid specific?  I'm sure I used to be able to wake up this machine when it was a windows box (shudder..) via WOL.

 

root@Tower:~# /boot/config/ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        [b]Wake-on: g[/b]
        Current message level: 0x00000007 (7)
        Link detected: yes

 

 

  • Author

There is usually a setting in the BIOS to enable/disable this.

In addition there is usually a setting in the BIOS to automatically power on the machine at a specific time.

 

These are usually in the APM or power management screens.

 

Some more information.

http://xlife.zuavra.net/index.php/60/

http://www.hackernotcracker.com/2006-04/wol-wake-on-lan-tutorial-with-bonus-php-script.html

 

Thank you for those links.  I had already looked in the BIOS and found no entries referring to WOL.  However I spotted in one of those articles you posted that sometimes WOL can be referred to as PME.  In the bios of my P4C800-e I found an entry:  Wake on PCI event.

 

In the help for this entry it mentioned generates a PME event... so I enabled this option and lo and behold, it now works  ;D

 

  • 4 months later...

It might also be a good idea to make this "shutdown sometime after midnight when the shares havent been accessed for xx hours.". This way you can use 2 to shut it down at 2am but if you use the box until 2:15 am it will shut down itself at 4.15 am. Otherwise we basically have made a box that will not have a way to power up for a few hours a day i.e. it will boot up and you will be racing to change the config before it powers itself down.

 

I'd also be very interested in some sort of timer or inactivity monitor that is conditional for shutting down the machine. Is there anything like this built into slackware already?

 

Phil/TW

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.