Reducing HDD spin-ups - editing crontab changes nothing

Hi, all,

I’m trying to reduce the number of times per day my hard drive spins up from idle, to reduce the physical wear on the drive. Rather a noob here, so please bear with me. I found posts mentioning editing the crontab to increase the interval of scheduled jobs as one way of accomplishing this, and was finally able to figure out how to do so. I successfully edited it from:

*/5 * * * * php -f /var/www/nextcloud/cron.php (run cron.php every 5 minutes)

to:

  • */3 * * * php -f /var/www/nextcloud/cron.php (run cron.php every 3 hours)

I confirmed that the edit had taken place, and also that it would survive a reboot. I timed the interval between HDD spin-ups, and found that they were 10 minutes apart - not 5 minutes, and certainly not the 3 hours I was looking for. It didn’t matter whether I was on the network (thinking that an outside request may have been triggering it) or not.

When I checked the crontab today after editing it last night, I saw that it had reverted back to the every 5 minute interval. Not sure if there’s some automatic update that’s overwriting it back to default.

I installed a few apps, so I suppose one or more of those could be triggering it, but I don’t know how to check that.

Running NextcloudPi 1.35.0, with Nextcloud version 20.0.8.1

Pretty confused here, and welcome any insight and assistance. Thanks!

Hello Skyhooker,

Running this command

does not run it every 3 hours, rather every 3 minutes! If you want to run cron every 3 hours, you have to add 0 in the beginning. Thus, your cron should look like below:

0 */3 * * * php -f /var/www/nextcloud/cron.php

I am not sure how your cron works, but for me, I had to add this to the cron root. I found mine under:

cd /etc

I hope this helps

Hi, Cyrus,

Thanks for the reply. I did not know about needing the leading zero - the example I found did not mention the need. I will give that a try. I appreciate the assistance!

P.S. - In the edited line I coped in my original post, that bullet symbol was actually an asterisk - not sure how that got changed when I saved the post. So I think I had it set for 3 hours, but still was missing that leading zero.

OK, I successfully edited the crontab as:

0 */3 * * * php -f /var/www/nextcloud/cron.php

I rebooted, waiting for the next drive spinup, and started the stopwatch. Spinup to spinup was still 10 minutes on the button, so not only did the original, unedited crontab schedule of every 5 minutes not affect the time between spinups, the edit I made to “every 3 hours” also had no effect. It seems clear that there’s some other process being triggered every 10 minutes, and that this crontab may not even be active. Is there a way to check that? I thought simply saving an edited crontab activated it and started the clock running.

Any ideas? Thanks!

I’d check the log files under /var/log especially /var/log/syslog

@Skyhooker Just as a sidenote: I wouldn’t recommend to change Nextclouds crontab to run just once every three hours. It can have unexpected side effects for Nextcloud since Nextcloud expects the cron to run every 5 minutes.

1 Like

Hello

My post is not a direct answer to your question or a solution to your problem. But rather a few thoughts about whether there is a problem at all, that needs to be solved, or whether you are even increasing the problem with your idea.

If you ask me, the only good reason to idle a disk in a server, is for power saving. In fact there are even people that say, disks used with aggressive power saving schemes in NAS’es tend to die rather quickly.

Unfortunately, there isn’t too much public data on this issue, but I would say that frequent spinups and spindowns can stress a disk even more than if you let it spin all the time. Whether the disk will last longer over time, depends also on how often you actually access the server. If you only access the server once a week, it probably makes sense to shut down the disks for the time the server is not beeing used. If you access it several times a day, probably not.

At the end of the day it comes down to how often you use the server, whether it is worth the hassle to try getting the drive idle mode somehow working, wich most likley will come with other unwanted side effects, like others already mentioned. I tend to say it’s not.

Beside of that… Unless you have multiple TBs of data, you could just buy an SSD for the data folder of your nextcloud and use the spining drives for backups and other stuff. That’s what I would do, respectively that is what I actually do. :slight_smile:

Hope that makes sense :slight_smile:

Hi Skyhooker,

when you say rebooted, did you mean just the nextcloud? or the entire machine? Remember that when you make changes to crontabs, you need to restart the cron services. I achieve this by issuing “service cron restart”