# If a Visitor is There to See: WP-Cron and the Clock of the Long Now

- Link: https://cagrimmett.com/2022/09/08/wp-cron-and-the-clock-of-the-long-now/
- Published: 2022-09-08T22:16:32-04:00
- Author: Chuck Grimmett

What do [WP-Cron](https://developer.wordpress.org/plugins/cron/) and the [10,000 Year Clock of the Long Now](https://en.wikipedia.org/wiki/Clock_of_the_Long_Now)
have in common?

They both only tell time if someone is there to see them.

_Huh?_

Most clocks have a power source to keep their faces updated. But in a [clock buried deep in a mountain](https://longnow.org/clock/),
why waste energy updating the clock face if no one is there to see it? Instead, 
why not use the humans who come to see it to wind a falling weight that will update
the clock face with the current time.

> Hillis and Brand plan, if they can, to add a mechanism whereby the power source
> generates only enough energy to keep track of time; if visitors want to see the
> time displayed, they would have to manually supply some energy themselves.
>  [https://en.wikipedia.org/wiki/Clock_of_the_Long_Now#Displaying_the_time_and_date](https://en.wikipedia.org/wiki/Clock_of_the_Long_Now#Displaying_the_time_and_date)

_Okay, cool. Now what about WordPress? Doesn’t it have a clock?_

Actually, no. Unlike its cron namesake in Linux, WP-Cron isn’t a clock at all. There
are some historical conversations you can look up in IRC and [trac](https://core.trac.wordpress.org/search?changeset=on&ticket=on&q=cron&page=98&noquickjump=1)(
fun fact: it used to be called [pseudo-cron](https://core.trac.wordpress.org/ticket/2425)!)
about why this is the case, but the short version is that WordPress is made to be
an application running on top of a system, and it isn’t guaranteed that it will 
have access to the system’s scheduler (on shared hosts, for example), so instead
with WP-Cron, all scheduled tasks are put into a queue that is checked with every
page load, and will run at the next opportunity (meaning the next page load). While
you can’t be 100% sure _when_ your task will run, you can be 100% sure that it will
run _eventually_. [[Source](https://developer.wordpress.org/plugins/cron/#why-use-wp-cron)]

If you are _very particular_ about your WP posts going up at a certain time, there
are ways you can hack pageviews, such as setting a service like [Uptime Robot](https://uptimerobot.com/)
to ping your website every minute. Or you can move to a host like WordPress.com,
WordPress VIP, or WPEngine that has a bit tighter integration with the system clock
and wp-cron. Or you can roll your own using [Lingon](https://www.peterborgapps.com/lingon/)
to interface with macOS’s launchd.

So if a post gets published on WordPress, it is because someone was there to see
it, and if someone sees the time on the Clock of the Long Now, they had to crank
it themselves. [Age-old conundrum](https://en.wikipedia.org/wiki/If_a_tree_falls_in_a_forest)
solved.

_h/t [Mark Drovdahl](https://mark.drovdahl.com/) for a conversation that sparked
this musing_