Web Weather > Weather Web Site Help

NWS Alerts script and Cron Jobs

(1/1)

K6GKM:
Hello everyone,

I've been using cron-job.org for years to execute my nws-alerts,php script, but recently I've had problems with my hosting provider "throttling" access.  I'll frequently get a 403 (Forbidden) error and often times the cron job will shut off due to multiple consecutive failures.  I've also not been able to find a way to white-list cron-job.org's IP addresses.

I figured I could set up a cron job through my hosting provider itself, but I'm running into issues there as well.  I'm trying to set the command "/usr/local/bin/php /hidden/for/privacy/nws-alerts.php" to run every minute (* * * * *).  The cron job itself is running, but the output of the script is odd, as if I have no zones configured:


--- Code: ---<!-- nws-alerts.php - V1.44 - 13-May-2023 -->
<!-- 0 unique Zone entries found. Zones='' -->
<!-- Cron job enabled -->
<!-- unable to open cache file -->
<!-- unable to open cache file -->
<!-- unable to open big icon cache file -->
<!-- Total process time: 0.0049 seconds -->
--- End code ---

It processes fine if I call nws-alerts.php from my browser...  anyone run into this issue before?  Appreciate any help.

FresnoEddy:
I am having this same problem with the nws-alerts.php script, getting the messages "unable to open cache file", etc. Were you able to find a fix for this?

saratogaWX:
To successfully run a cron job locally on your webserver, you have to have three things:
1) the full path to the php command for your site (use check-fetch-times.php?show=info to see the PHP full path)
2) issue a change directory (cd) command to your document root (the check-fetch-times.php?show=info shows that also)
3) then you can construct a cron command like
--- Code: ---cd $HOME/public_html; /full/php/path/php -q nws-alerts.php > nws-status.txt 2>&1
--- End code ---
replacing /full/php/path with the path shown in 1) above and public_html with the directory used as your document root (like www, httpdocs, public_html, etc) as shown in 2) above.

Set it to use */5 * * * *  (every 5 minutes) and you're set.

The result of a cron execution should be available in nws-status.txt on your site.

nws-alerts.php won't run correctly without the cd to your document root in the cron command as cron will default to your home/FTP directory, not your document root, so it can't find the other configuration files needed to run.

FresnoEddy:
Thank you, Ken. That worked and now makes sense to me as well! I appreciate your help with this as well as all of your work on the templates.

Navigation

[0] Message Index

Go to full version