Email notifications are not being sent when cron jobs execute, but the same code works perfectly when run manually from the command line. This affects multiple notification types including:
- Cloudflare Analytics reports (
LinkedData::Utils::Notifications.cloudflare_analytics)
- OBO Foundry sync reports (
LinkedData::Utils::Notifications.obofoundry_sync)
Steps to reproduce:
- Log into staging and change to
/opt/ontoportal/ncbo_cron
- Run the OBO Foundry synchronization script manually:
./bin/ncbo_obofoundry_sync.rb
Notice that the job completes successfully with no errors:
[2025-07-23 15:23:21] INFO: Starting OBO Foundry synchronization...
I, [2025-07-23T15:23:21.712035 #1182414] INFO -- : Found 262 OBO Foundry ontologies
I, [2025-07-23T15:23:21.712182 #1182414] INFO -- : 208 OBO Foundry ontologies are currently active
I, [2025-07-23T15:23:21.712226 #1182414] INFO -- : Missing OBO Foundry ontology: Biomarker Ontology (bmont)
[2025-07-23 15:23:21] INFO: OBO Foundry synchronization completed successfully in 0.75 seconds
[2025-07-23 15:23:21] INFO: OBO Foundry sync process finished
If you then log into the ncbo.developers Gmail account, you can see that the email notification was successfully issued:
However, when the same job is run as a cron job, no email message is sent. I wrapped the notification code in a rescue block:
begin
LinkedData::Utils::Notifications.obofoundry_sync(missing_onts, obsolete_onts)
rescue StandardError => e
@logger.error("Notification failed: #{e.class}: #{e.message}")
@logger.error("Backtrace: #{e.backtrace.first(5).join(' | ')}")
raise
end
But the scheduler.log file shows no errors/exceptions when the code is run as a cron job:
D, [2025-07-23T15:30:00.117496 #1182494] DEBUG -- : ncbo_cron_obofoundry_sync -- Lock acquired
I, [2025-07-23T15:30:00.117809 #1182494] INFO -- : Start generating OBO Foundry synchronization report...
I, [2025-07-23T15:30:00.532924 #1182494] INFO -- : Found 262 OBO Foundry ontologies
I, [2025-07-23T15:30:00.533068 #1182494] INFO -- : 208 OBO Foundry ontologies are currently active
I, [2025-07-23T15:30:00.533107 #1182494] INFO -- : Missing OBO Foundry ontology: Biomarker Ontology (bmont)
I, [2025-07-23T15:30:00.791022 #1182494] INFO -- : OBO Foundry synchronization report job completed in 0.671604701 sec.
I, [2025-07-23T15:30:00.791089 #1182494] INFO -- : Finished generating OBO Foundry synchronization report
Email notifications are not being sent when cron jobs execute, but the same code works perfectly when run manually from the command line. This affects multiple notification types including:
LinkedData::Utils::Notifications.cloudflare_analytics)LinkedData::Utils::Notifications.obofoundry_sync)Steps to reproduce:
/opt/ontoportal/ncbo_cron./bin/ncbo_obofoundry_sync.rbNotice that the job completes successfully with no errors:
If you then log into the
ncbo.developersGmail account, you can see that the email notification was successfully issued:However, when the same job is run as a cron job, no email message is sent. I wrapped the notification code in a rescue block:
But the
scheduler.logfile shows no errors/exceptions when the code is run as a cron job: