# Cron failure alert

**URL:** <https://farmos.discourse.group/t/cron-failure-alert/2596>\
**Category:** Hosting farmOS\
**Created:** [September 6, 2026, 12:43pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596 "2026-09-06T12:43:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [September 6, 2026, 12:43pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/1 "2026-09-06T12:43:51Z")

</div>

I rely on Cron to generate some logs.  
Cron may fail sometimes and I need to know about this.

Are there any best practice for this?  
Maybe [Cron Fail Alert](https://www.drupal.org/project/cron_fail_alert), or is that an unneeded dependency?

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 6, 2026, 3:23pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/2 "2026-09-06T15:23:59Z")

</div>

Do you have a system cron job set up to call Drupal’s cron? Or are you relying on Drupal’s default cron trigger?

Drupal has a default cron system that will run it automatically, but the only way that gets triggered is if visitors are requesting pages on the site. This works fine for websites if they have steady traffic, but for private intranet sites like farmOS that isn’t reliable.

The better way is to set up a system cron job that calls the Drupal cron endpoint.

farmOS documentation: [Installing farmOS | farmOS](https://farmos.org/hosting/install/#cron)

Full documentation: [Client Challenge](https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/cron-automated-tasks-overview)

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 6, 2026, 3:28pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/3 "2026-09-06T15:28:03Z")

</div>

If you have a system cron and it’s still failing, and you want to set up some kind of heartbeat monitor to debug this, you could write a script that uses Drush to read the `last_run` timestamp of cron and alert you if it doesn’t get updated as frequently as you want.

`drush state:get system.cron_last`

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 6, 2026, 3:31pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/4 "2026-09-06T15:31:53Z")

</div>

> [@pat](#):
>
> Maybe [Cron Fail Alert](https://www.drupal.org/project/cron_fail_alert), or is that an unneeded dependency?

Out of curiosity I looked at this module to see how it works. It runs some logic every time a page is requested that checks the `system.cron_last` state that I mentioned in my previous comment.

> **[src/EventSubscriber/CronFailAlertSubscriber.php ·...](https://git.drupalcode.org/project/cron_fail_alert/-/blob/a6e437f921e84f70e2a10561cf2c7a6b1cc9ea8e/src/EventSubscriber/CronFailAlertSubscriber.php#L101)**
>
> For more information about this repository, visit the project page at https://www.drupal.org/project/cron\_fail\_alert

So it only works if the site has steady traffic, just like the default Drupal cron trigger mechanism.

So if infrequent traffic is the cause of your issues, then it won’t help.

Either way, this would be my recommendation, if you aren’t doing it already:

> [@mstenta](#):
>
> The better way is to set up a system cron job that calls the Drupal cron endpoint.
> 
> farmOS documentation: [Installing farmOS | farmOS](https://farmos.org/hosting/install/#cron)

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [September 6, 2026, 8:04pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/5 "2026-09-06T20:04:28Z")

</div>

Thank’s for the info.

Problem was that Cron did not run due to some locale translation que. Did not notice until I missed some todo’s.

At first I just had Node-Red trigger the url listed at the cron page.  
It does not give an alert when failling, but propably doable.

The Cron Fail Alert may be ok for my use at this point, since I use farmOS to view the logs brought in by the cron tasks.

I understand system cron should be most reliable, so I’ll try that combined with ntfy.sh on error

EDIT:  
I put in this line in crontab. It should send me a ntfy notification if it fails for some reason.

`0 */2 * * * docker exec farmos-www-1 drush cron || curl -s -H "Authorization: Bearer my-secret-token" -H "X-Tags: no_entry" -d "farmOS cron failure" ``https://my-ntfy-server/mytopic`

Not sure, but I think drush cron will throw an error if it fails, and the curl command should execute.  
🤞

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 6, 2026, 9:51pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/6 "2026-09-06T21:51:13Z")

</div>

> [@pat](#):
>
> Problem was that Cron did not run due to some locale translation que. Did not notice until I missed some todo’s.

Ah I see! So it was a silent failure due to a code issue. Do you have any errors in logs? Maybe it can be fixed.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [September 7, 2026, 6:30am UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/7 "2026-09-07T06:30:47Z")

</div>

I think it is sort of fixed already for drupal version 11  
The error did not throw an exception. Just crash cron.

So maybe my notify alert from crontab never would have fired in this case.

> **[Improve the error message thrown in PoStreamReader::readLine() when...](https://www.drupal.org/project/drupal/issues/3301239)**
>
> Problem/Motivation When a Drupal site does not have their translations folder correctly set up, a confusing error occurs when a new module is enabled: $ drush en honeypot \> \[notice\] Checked fr translation for honeypot. \> \[notice\] Checked nl...

---

<div class="post-metadata">

**Author:** ![ledgar](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/ledgar/32/1943_2.png) [@ledgar](https://farmos.discourse.group/u/ledgar)\
**Post date:** [September 15, 2026, 1:17am UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/8 "2026-09-15T01:17:01Z")

</div>

> [@pat](#):
>
> I put in this line in crontab. It should send me a ntfy notification if it fails for some reason.
> 
> `0 */2 * * * docker exec farmos-www-1 drush cron || curl -s -H "Authorization: Bearer my-secret-token" -H "X-Tags: no_entry" -d "farmOS cron failure" ``https://my-ntfy-server/mytopic`

If a cron job produces output (STDOUT/STDERR) ~~or (I think?) fails with non-zero exit code~~, a system usually sends an email, to root@localhost unless you configured otherwise. I often use that to my advantage so a failure winds up in my inbox.

EDIT: pretty sure it’s only the output that will trigger auto system email

But there is a gotcha, the email subject line is the cron command string! So not good to have secrets embedded there. I make a separate script with memorable name, e.g. `confirm-farmos-cron.sh` in this case maybe, so that is my cron command and all details/secrets are inside the script.

Anyway just some FYi in case it helps!

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [September 15, 2026, 2:16pm UTC](https://farmos.discourse.group/t/cron-failure-alert/2596/9 "2026-09-15T14:16:26Z")

</div>

Thanks. Nice to know.
