Best cron settings

Started by asmith, February 09, 2024, 01:08:01 AM

Previous topic - Next topic

asmith

I have an Ubuntu server with root access and I'd like to disable web cron. I want to know what is the best way to run cron from the server?

I could run it every 30 seconds or so.
* * * * * /path/to/smf/cron.php >> cron.log
* * * * * sleep 30; /path/to/smf/cron.php >> cron.log

Ideally I like the cron to do the tasks as soon as they arrive... Any better suggestions?

Arantor

30 seconds is a good value to have. More frequently than that is a bad idea.
Holder of controversial views, all of which my own.


asmith

Could you elaborate why less than 30 is a bad idea? In case the previous attempt is taking more than 30 seconds to complete?

Sesquipedalian

I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Arantor

But also to avoid other concurrency issues around the database locking, the reality is that people are not going to notice if they don't get their alerts *immediately*. They really don't.

Case in point: I have a setup where I push notifications of new posts/new replies to Discord. I explicitly make this wait 2 minutes before doing so to let people fix any mistakes. No one is bothered by this delay.

The default setup tries to leverage browsers hitting it every 15 seconds but allowing for browsers to assume the response is cached (because that was what Chrome was doing when I wrote that code) so in practice it ended up triggering the queue more like every 30 seconds anyway.

Honestly even every minute would probably be frequently enough unless your forum is massive.
Holder of controversial views, all of which my own.


Advertisement: