intelligent startup/shutdown schedule for Jails

Status
Not open for further replies.

Tosh Patel

Cadet
Joined
Jul 9, 2015
Messages
1
Many folks on the forum mention that their hard drives never go to sleep because some of the jail apps keep logging to the drive. Solutions to remedy this involves moving the jail to SSD or somewhere else which seems difficult to me. I was thinking of an alternate solution.

Can a startup/shutdown feature be added to the Jail configuration? The program in the jail (in my case plexmedia server) can override the shutdown if they need to be running for some reason. Once the jail app is ready to be shutdown, it can remove the override. Then, FreeNAS can determine if the jail app should be shutdown at that time and actually shut it down.

The override is important since the jail app could actively being used (someone is still watching a movie), so after an idle timeout, the jail app can remove the override.

(a side note. I wish there was a way for FreeNAS to know when my TV is pinging the server and startup the specific jail app... is there a way to do that? )

- Tosh
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Things do not work that way and what you are asking for is some serious customization of code but it would be only useful for very specific things. I would not expect that to ever be included in FreeNAS.

The good thing is I guess you could theoretically make some custom applications to handle what you want and manually add those into FreeNAS.

When it comes to hard drives never sleeping, in a NAS that is generally a very good thing for many reasons which I assume you have already read about. The solution is very simple if the individual really want the drives to sleep, add a SSD for the jails and move the system.dataset to the SSD as well. This solution is much easier than building custom applications to handle what you desire.
 
D

Deleted47050

Guest
I agree with @joeschmuck. It's probably also worth pointing out that, should you decide to go the SSD way, it doesn't necessarily mean you have to splurge on a huge ssd if you are moving your jails and System dataset on it. From what I could see on my system, even a 40 GB ssd would be plenty for this.

One important note though: if you plan on doing this, remember that the system dataset requires redundancy, so you really want a mirror for your ssd.

Which probably also means that you might be better off just leaving your drives running all the time.
 

solarisguy

Guru
Joined
Apr 4, 2014
Messages
1,125
@Tosh Patel, current drives from model lines Blue, Green and Red from Western Digital use at most 3.4W when idle (while at the same capacity, WD Red Pro, WD Re and WD Black use 7.4W or less when idle).

3.4W is comparable to power consumption of a case fan. With a 6TB drive, that is less than 0.6W/TB spinning...

And hard drives that are not spinning (in standby or sleep mode) still draw power.
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
You can labor for the balance of your life, trying to get the FreeNAS to be I/O-quiet enough to allow the main pool drives to sleep, and get nowhere.

It's really a fool's errand in any case. AND, as others have already stated, "spinning down NAS drives" is not something you usually want to do. The drives live longest when they are constantly on, and any "energy savings" you think you would get is vastly more than offset by the huge start up energy to re-energize the platters, and the cost of the wear/tear on the drives.

I wish we could put this whole concept to bed. Leave your disks spinning. There's a good reason why every single one of the major contributors to the FreeNAS forums operate a 24/7 main pool with no spindown.
 
Joined
Apr 9, 2015
Messages
1,258
While I fully agree that leaving the disks spinning is the best thing you can do. I do have a theoretical question that could be useful for parents.

Wouldn't it be possible rather than to stop or start a jail completely to have cron issue a start stop command for say plex? It could be an advantage to someone who has kids and want to make sure they go to bed rather than stay up all night and watch movies. Basically at whatever predetermined time the cron command would run and then shut down the plex server. Then at another time the command could be set to start the plex server back up so it would be available again. On top of that how would that command be passed to a particular jail?
 
D

Deleted47050

Guest
While I fully agree that leaving the disks spinning is the best thing you can do. I do have a theoretical question that could be useful for parents.

Wouldn't it be possible rather than to stop or start a jail completely to have cron issue a start stop command for say plex? It could be an advantage to someone who has kids and want to make sure they go to bed rather than stay up all night and watch movies. Basically at whatever predetermined time the cron command would run and then shut down the plex server. Then at another time the command could be set to start the plex server back up so it would be available again. On top of that how would that command be passed to a particular jail?

This you can do, since you are simply stopping/starting a service within the jail without any impact on disk behavior. You can use that specific jail's cron to run /usr/sbin/plexmediaserver stop/start at the times you want.
 

9C1 Newbee

Patron
Joined
Oct 9, 2012
Messages
485
It could be an advantage to someone who has kids and want to make sure they go to bed rather than stay up all night and watch movies.

Use more backhand.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
It could be an advantage to someone who has kids and want to make sure they go to bed rather than stay up all night and watch movies.
This is a parenting question, not a FreeNAS questions. Take any devices away from the kids and punish them for a violation, no idle threats.
Use more backhand.
I can't agree more.
 
Joined
Apr 9, 2015
Messages
1,258
LOL, I agree and have zero children in the home.

But I could see other places where it could be an advantage as well. Like shutting down a VPN connection automatically at certain times or if you have a program in a jail that while it works well seems to have an issue after a certain amount of time. Probably quite a few other uses that I can't even think of right now.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
if you have a program in a jail that while it works well seems to have an issue after a certain amount of time.

Well, if you've a program that have an issue after a certain amount of time then it doesn't work well.
 
D

Deleted47050

Guest
Lol stop bashing the poor guy for no reason. He asked a legitimate question, doesn't matter what the driver of that request is. The way I see it, what he asked for is just how to use cron to do something inside a jail. Starting or stopping a service doesn't really make any difference.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
The way I see it, what he asked for is just how to use cron to do something inside a jail. Starting or stopping a service doesn't really make any difference.
I didn't think that was the question but rather asking how to start or stop an application running within a jail from outside the jail all while ensuring it's a safe operation.

I guess the short answer to this is, "Sure, it could be done."

Starting things up is a no brainer. But, off the top of my head I wouldn't stop an application from outside the jail, I'd do it all from within the jail and have a script evaluate when is a good time to shutdown the jail or maybe just the application desired to be shutdown. For example lets say you want to run PLEX from 8AM to 9PM, well you create two CRON entries to start PLEX at 8AM and stop PLEX at 9PM, no script required. And you could do this for the entire jail if you like but you need the CRON in the host to start the jail and the CRON in the jail to shutdown the jail. If you need to get a little fancier such as evaluating if PLEX is currently hosting some streaming, well you will need to evaluate that value (whatever that is, possibly throughput of the specific IP address for the jail) and once it is no longer streaming, force it down. If you are dealing with a plugin, there is more complexity to it which I'm not willing to get into because I haven't messed with plugins in quite a while and I'd rather not again.

So yes these things can be done but they are not standard things and not for the faint of heart. I'm not saying anyone here asking for help is looking for someone else to do the work for them but If you're not willing to invest the time to figure it out and how to write scripts, configure the CRON, etc... , in my opinion then you shouldn't be doing this. If you make an honest attempt at trying to figure it out and doing a fair amount of research, show us your results and failures, hell, I'll help out. How does that saying go... Give the man a fish and he will eat for one day, Teach the man to fish and he will eat for a lifetime. I'm a lifetime kind of guy, even if you only use this once now, one day it may help you with something else in a different project, even in a different programming language.

I hope this answers the question but I do not see this as a realistic feature request.
 
D

Deleted47050

Guest
I didn't think that was the question but rather asking how to start or stop an application running within a jail from outside the jail all while ensuring it's a safe operation.

I guess the short answer to this is, "Sure, it could be done."

Starting things up is a no brainer. But, off the top of my head I wouldn't stop an application from outside the jail, I'd do it all from within the jail and have a script evaluate when is a good time to shutdown the jail or maybe just the application desired to be shutdown. For example lets say you want to run PLEX from 8AM to 9PM, well you create two CRON entries to start PLEX at 8AM and stop PLEX at 9PM, no script required. And you could do this for the entire jail if you like but you need the CRON in the host to start the jail and the CRON in the jail to shutdown the jail. If you need to get a little fancier such as evaluating if PLEX is currently hosting some streaming, well you will need to evaluate that value (whatever that is, possibly throughput of the specific IP address for the jail) and once it is no longer streaming, force it down. If you are dealing with a plugin, there is more complexity to it which I'm not willing to get into because I haven't messed with plugins in quite a while and I'd rather not again.

So yes these things can be done but they are not standard things and not for the faint of heart. I'm not saying anyone here asking for help is looking for someone else to do the work for them but If you're not willing to invest the time to figure it out and how to write scripts, configure the CRON, etc... , in my opinion then you shouldn't be doing this. If you make an honest attempt at trying to figure it out and doing a fair amount of research, show us your results and failures, hell, I'll help out. How does that saying go... Give the man a fish and he will eat for one day, Teach the man to fish and he will eat for a lifetime. I'm a lifetime kind of guy, even if you only use this once now, one day it may help you with something else in a different project, even in a different programming language.

I hope this answers the question but I do not see this as a realistic feature request.

Re-reading his original question, I think you are right, as it seemed to ask how to shutdown a jail from the outside. I focused on how to stop the Plex service itself from within the jail since that was his goal (not to mention definitely easier to implement) and one of his later questions.

Agreed with everything else you said though.
 
Status
Not open for further replies.
Top