Jump to content

Shutdown Unraid from a Script in Unraid not from another PC, On a certain time?


Recommended Posts

Hi,

 

The title kind of says it all - I have set my Bios to power on my server at a certain time - IE 5:00pm - but I would like to power off the Unraid server from Unraid not from another pc at a certain time.

 

I have searched and searched i see lots of shutdown scripts for just turning off the server but none on a certain time or day?

 

Anybody have any ideas ???

 

Thanks

AJ

Link to comment

Hi,

 

The title kind of says it all - I have set my Bios to power on my server at a certain time - IE 5:00pm - but I would like to power off the Unraid server from Unraid not from another pc at a certain time.

 

I have searched and searched i see lots of shutdown scripts for just turning off the server but none on a certain time or day?

 

Anybody have any ideas ???

 

Thanks

AJ

Have you tried looking in the wiki?  

Specifically in the FAQ in the wiki?

http://lime-technology.com/wiki/index.php?title=FAQ#How_can_I_get_my_unRAID_server_to_shut_down_at_the_same_time_every_day.3F

 

Joe L.

Link to comment

Joe - I guess i was tired when searching, the wiki says the following: How can I get my unRAID server to shut down at the same time every day?

 

Make sure that Power Down (an UnRAID Add On) is installed, then add an at command to your go script, similar to the following, which stops the array and powers down the server at 11PM:

 

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

 

 

 

 

Question - i downloaded the powerdown-1.02-noarch-unRAID.tgz do i put that file in the main boot of the flash drive? Or does it need to go in a certain folder?

 

The rest seems easy ;D

Link to comment

Joe - I guess is was tired when searching, the wiki says the following: How can I get my unRAID server to shut down at the same time every day?

 

Make sure that Power Down (an UnRAID Add On) is installed, then add an at command to your go script, similar to the following, which stops the array and powers down the server at 11PM:

 

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

 

 

 

 

Question - i downloaded the powerdown-1.02-noarch-unRAID.tgz do i put that file in the main boot of the flash drive? Or does it need to go in a certain folder?

 

The rest seems easy ;D

Most of us create a "packages" folder for the *.tgz files.  It is easier to manage them all when they are in the same place.

 

From the linux command line type

mkdir /boot/packages

to create it.

 

Put the .tgz file there.  If using window's explorer, /boot/packages will be at \\tower\flash\packages

You do not want to un-compress of extract the individual files in it.  The "installpkg" command does that for you.

 

At the bottom of your config/go script, add a line as shown in the wiki:

http://lime-technology.com/wiki/index.php?title=Powerdown_script

 

That line will be:

CTRLALTDEL=YES LOGSAVE=30 installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz

 

Than, below that, add one more line to the end of the "go" script with

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

 

Those same two lines can be entered on the command line, to install the powerdown package, and to schedule the power down itself for the first time.  The next time you reboot the lines in the "go" script will be invoked and you'll be set up as you requested.

 

At any time you can type

atq

to see the job numbers of the "at" queue pending.

 

You can type

atrm job_number

to cancel a job (in case you did not want the server to shut down on a specific day)

 

You can type

at -c job_number

to see the specifics of a given job.

 

Joe L.

Link to comment

What will happen happen unRAID is supposed to poweroff and some user is copying files at the same time? Will it just execute the poweroff command and break the file copy or wait until it finishes and then power off?

 

Would be great if something similar can be implement in the same manner as the s2ram script.

Link to comment

What will happen happen unRAID is supposed to poweroff and some user is copying files at the same time? Will it just execute the poweroff command and break the file copy or wait until it finishes and then power off?

 

Would be great if something similar can be implement in the same manner as the s2ram script.

It will powerdown, the /sbin/powerdown command will kill off the file-transfer. 

It is why I gave instructions on how to cancel a given "at" job.

 

 

Link to comment

Will it just execute the poweroff command and break the file copy or wait until it finishes and then power off?

 

Would be great if something similar can be implement in the same manner as the s2ram script.

 

The poweroff command will stop all running processes regardless of activity.

The poweroff command cannot be retrofitted like the s2ram script.

what's needed is a new script that behaves like the s2ram script which is run at a certain time, then calls the poweroff command. (not the other way around).

 

If poweroff is triggered by a ups event, I doubt you want it to wait around until the system is idle.

 

Link to comment

WeeboTech, I never noticed if you published the new version of the powerdown script, with the changes we discussed a few weeks ago.

Can you point me to the new link if it's available? The wiki still shows the old version.

 

I have not published it yet. I started to work on it and I had to back off from the typing.

When I get going with the typing, I forget, start to use all the fingers, stretch the hand and hurt it.

I was building a test unraid server and realized I cannot squeeze my hand well enough to hold the screws either.  :(

I have to take it easy, but it should be done soon.

Link to comment

Joe - the script worked one time.....

 

Running Pro 4.5.1 Now - So i did some t/s and found out that my bios clock which is in (military time) is being reset somehow on every reboot, So I installed my correct timezone file into the config dir (using custom - with no pools) and reset my bios clock to the correct time and rebooted the server, and set the unraid time in the settings and it took, Noticed the unraid time is not military time!

 

Stop the array and then rebooted the server, Noticed as the server is rebooting that one of the messages says (saving sys time to hardware clock utc) the server reboots and the unraid time is still accurate, But if i stop the array and reboot back into the bios the hardware clock is off now by like 8:00 hours. :-\

 

Looks like Unraid is changing my Bios Clock?

 

This is not ok because I set my server to boot up at a certain time using the Bios

 

syslog attached...

 

 

Thanks in advance

AJ

 

                           

 

 

syslog-2010-03-27.txt

Link to comment
  • 3 months later...

WeeboTech, I never noticed if you published the new version of the powerdown script, with the changes we discussed a few weeks ago.

Can you point me to the new link if it's available? The wiki still shows the old version.

 

I have not published it yet. I started to work on it and I had to back off from the typing.

When I get going with the typing, I forget, start to use all the fingers, stretch the hand and hurt it.

I was building a test unraid server and realized I cannot squeeze my hand well enough to hold the screws either.  :(

I have to take it easy, but it should be done soon.

Any update on that powerdown-1.03?

 

I installed powerdown-1.02, and did this from a telnet session....

root@v454:~#
root@v454:~# cd /mnt/disk1/
root@v454:/mnt/disk1# powerdown

...the server never powered down!

 

Can't it somehow kick me out of that telnet session and release my hold of disk1?

 

Link to comment

Any update on that powerdown-1.03?

I installed powerdown-1.02, and did this from a telnet session....

root@v454:~#
root@v454:~# cd /mnt/disk1/
root@v454:/mnt/disk1# powerdown

...the server never powered down!

 

Can't it somehow kick me out of that telnet session and release my hold of disk1?

 

 

I'll release something this weekend. I was planning to anyway.

I had to get my larger system stable, and my smaller test bed ready for testing this.

I think the powerdown script is waiting or killing the session that is on the disk, which happens to be the script doing the powerdown.

 

So I need to add a CD in the script, or fork it into the back ground or complain and exit.

 

I've decided to do thinks simple in regards to the rc.unraid directory

 

S* scripts get run if you do rc.unraid start

K* scripts get run if you do rc.unraid stop

K* and S* can point to the same script or not.

Nice and simple. In the first incarnation there are no protective mechanisms built in. (Unless I get adventurous).

 

In the following versions, I'll write a C utility to run the user supplied scripts with a pipe back to the parent.

stdout/stderr will go to the parent and the parent will log all output from the child.

If the child does not provide output after a determined number of seconds, the child will be killed off.

 

I would have started on this, but I'm working diligently on my new locate replacement tool.

 

To me that's a bigger issue because the standard locate was crashing my system with OOM errors.

Plus I really want an MD5 Signature for all my files after seeing all the format problems and corruptions.

Link to comment

WeeboTech, I never noticed if you published the new version of the powerdown script, with the changes we discussed a few weeks ago.

Can you point me to the new link if it's available? The wiki still shows the old version.

 

I have not published it yet. I started to work on it and I had to back off from the typing.

When I get going with the typing, I forget, start to use all the fingers, stretch the hand and hurt it.

I was building a test unraid server and realized I cannot squeeze my hand well enough to hold the screws either.  :(

I have to take it easy, but it should be done soon.

Any update on that powerdown-1.03?

 

I installed powerdown-1.02, and did this from a telnet session....

root@v454:~#
root@v454:~# cd /mnt/disk1/
root@v454:/mnt/disk1# powerdown

...the server never powered down!

 

Can't it somehow kick me out of that telnet session and release my hold of disk1?

 

In recent editions of unRAID, lime-technology added their own version of "powerdown" that basically just presses the button on the web-interface.   The web-interface will not kill processes, but instead will wait for all the disks to not be bust before powering down.

 

Since your "cd" to /mnt/disk1 forces it to be busy, since it is then the current directory of your shell, unRAID will not shut itself down.

 

Now, the complication lime-technology introduced is that its "powerdown" is ahead of WeeboTech's in the default search PATH.

If you just type

powerdown

you will not get the command WeeboTech wrote, the one that will terminate processes, but instead you'll get the one pressing the button on the web-interface.    If the web-interface was terminated by the out-of-memory kernel process, typng "powerdown" will have no effect at all since the button on the web-interface is not there to be pressed.

 

To invoke WeeboTech's version you MUST use a full path the the program and instead type:

/sbin/powerdown

 

Joe L.

 

 

Link to comment

Tom has said he will be putting some callouts into unRAID for various events.... you might want to wait to see what he implements before going too far down the development path.

 

Thanks for the note. It's why I held off. It's also been a while since the suggestion of callouts. Running of S*/K* scripts without massive checking will be quick. It's only a little more then what is occurring today with the powerdown rc.unRAID script.

 

In regards to running a shell with captured output and timeout, it's a tool I've been wanting for a while and will be made anyway. If it gets used for this or not is dependent on how unRAID progresses.

Link to comment

WeeboTech, I never noticed if you published the new version of the powerdown script, with the changes we discussed a few weeks ago.

Can you point me to the new link if it's available? The wiki still shows the old version.

 

I have not published it yet. I started to work on it and I had to back off from the typing.

When I get going with the typing, I forget, start to use all the fingers, stretch the hand and hurt it.

I was building a test unraid server and realized I cannot squeeze my hand well enough to hold the screws either.  :(

I have to take it easy, but it should be done soon.

Any update on that powerdown-1.03?

 

I installed powerdown-1.02, and did this from a telnet session....

root@v454:~#
root@v454:~# cd /mnt/disk1/
root@v454:/mnt/disk1# powerdown

...the server never powered down!

 

Can't it somehow kick me out of that telnet session and release my hold of disk1?

 

In recent editions of unRAID, lime-technology added their own version of "powerdown" that basically just presses the button on the web-interface.   The web-interface will not kill processes, but instead will wait for all the disks to not be bust before powering down.

 

Since your "cd" to /mnt/disk1 forces it to be busy, since it is then the current directory of your shell, unRAID will not shut itself down.

 

Now, the complication lime-technology introduced is that its "powerdown" is ahead of WeeboTech's in the default search PATH.

If you just type

powerdown

you will not get the command WeeboTech wrote, the one that will terminate processes, but instead you'll get the one pressing the button on the web-interface.    If the web-interface was terminated by the out-of-memory kernel process, typng "powerdown" will have no effect at all since the button on the web-interface is not there to be pressed.

 

To invoke WeeboTech's version you MUST use a full path the the program and instead type:

/sbin/powerdown

 

Joe L.

 

 

 

I probably did not explain myself clearly, sorry.  I am well aware of all that you explained above.  

I installed Weebo' powerdown from unmenu and removed the stock powerdown.  

 

In my example above I was sitting on  /mnt/disk1/  on purpose, trying to see if Weebo' powerdown will do its job,

and power down the computer regardless of who is keeping busy what.  It didn't.

 

To accomplish that goal I had to write my own crude version of powerdown that has the following:

pkill emhttp
/root/samba stop
/etc/rc.d/rc.inetd stop
pkill telnetd
fuser -k /dev/md*
sync ; echo 3 > /proc/sys/vm/drop_caches ; swapoff -a
umount /dev/md*
/root/mdcmd stop
poweroff

That did it.

 

 

Link to comment

That series of commands will not work if there are any mounted file-systems on mount-points on the disks.

Well, the commands worked.  And it's the best I've got in cases when it's either that or yanking the power cord from the wall.

 

Link to comment

That series of commands will not work if there are any mounted file-systems on mount-points on the disks.

Well, the commands worked.  And it's the best I've got in cases when it's either that or yanking the power cord from the wall.

 

Oh, it will work for most cases, but... there are some add-on packages that use a loop mount of a filesystem... It will not work for those if mounted on one of your data disks directories used as a mount point, or if a swapfile was configured and enabled on one of them and currently used by the OS.

 

You are correct though... What you did is better than yanking the cord from the wall.

 

Joe L.

Link to comment

...or if a swapfile was configured and enabled on one of them and currently used by the OS.

Good point.  That's easily remedied with a `swapoff -a`.  (The above script updated accordingly.)

 

Oh, it will work for most cases, but... there are some add-on packages that use a loop mount of a filesystem...

It will not work for those if mounted on one of your data disks directories used as a mount point

Any such package that comes to your mind?

 

Link to comment

Archived

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

×
×
  • Create New...