Page 1 of 1

Meteotemplate cron job for Cumulus realtime.txt

Posted: Wed 29 Jun 2016 7:07 pm
by stefanbagnato
Hi All,

I am working on a getting the cron job for the data update from CumulusMX to Meteotemplate working. Currently, the realtime.txt file is in C:\CumulusMX. So, in the cumulus.php file in meteotemplate's update folder, I list the relative path as C:\CumulusMX\realtime.txt. When I run the script/cron job, it throws an error:


Latest DB record timestamp detected: 1969-12-31 19:00:00
Latest cached timestamp detected: 1969-12-31 19:00:00
Smallest interval between uploads to database set to: 60 seconds.
Difference between latest db timestamp and cached timestamp: 0 seconds.
The difference between last db update and current data is not yet larger than the set interval. Current data is saved into temporary cache.

I went into myPHPAdmin and created a fake line of data. When I reran the script, I get:

Latest DB record timestamp detected: 2016-06-28 20:40:00
Latest cached timestamp detected: 1969-12-31 19:00:00
Smallest interval between uploads to database set to: 300 seconds.
Difference between latest db timestamp and cached timestamp: -1467160800 seconds.
The difference between last db update and current data is not yet larger than the set interval. Current data is saved into temporary cache.

So, it knows there is something in the database, but still can't write anything anywhere including to the cache. Next, I copied the latest realtime.txt into \wwwroot\update and set the path in cumulus.php to "realtime.txt". I reran the script again, and it worked.

So, my question is, barring a permissions issue (my account has full access to C:\CumulusMX so I wouldn't think it would be..), what else might be the problem with my setup?

FYI, my station is a VP2, and I am using Server 2012 R2 with IIS on my personal server.

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Wed 29 Jun 2016 7:33 pm
by steve
I know nothing at all about how Meteotemplate works, but presumably the cumulus.php script runs on the server, not on your local PC? You're giving it the location of the realtime.txt file on your PC rather than the server, are you not? I think you need to be giving it the location on your server. Even though the server is IIS (and perhaps it is actually the same machine as is running Cumulus?) I don't think you can supply a path in a PHP script in the form C:\... I think it has to involve the wwwroot rather than the Windows filestore, that's all the web server understands.

But I could be wrong...

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Wed 29 Jun 2016 8:34 pm
by stefanbagnato
Hi Steve

I think I understand what you are saying. The server and PC are one in the same. But I get the notion that the wwwroot folder is separate in a sense. I don't have access to Cumulus at this moment, otherwise I would look myself, but is there an ability in Cumulus to specify the location of the realtime.txt file? So instead of saving it to C:\CumulusMX, saving it somewhere else (as in the wwwroot)? Alternatively, I could probably write something to run a continuous (maybe to the minute?) copy of the file in C:\CumulusMX to the correct location in wwwroot. Hopefully that makes sense..

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Thu 30 Jun 2016 1:28 am
by PaulMy
I may be misunderstanding your issue, but if you have Cumulus realtime.txt on your webserver then the /update/cumulus.php?password=xxxxx should be taking data from realtime.txt and upload to the alldata MySQL database used by Meteotemplate. The Metetemplate setup.php is where you set the path to realtime.txt. I have Cumulus Toolbox uploading realtime.txt to my webserver http://www.komokaweather.com/weather/realtime.txt. For my Meteotemplate setup I have a cron-job running http://www.komokaweather.com/j-template ... word=xxxxx at 5 minute interval http://www.komokaweather.com/j-template
So instead of saving it to C:\CumulusMX, saving it somewhere else
For another template I have created a second duplicated realtime.txt (realtimeT.txt) to be processed and uploaded as realtime.txt by Cumulus to another specific folder accessed by this alternate template.

Paul

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Thu 30 Jun 2016 6:43 am
by steve
stefanbagnato wrote:is there an ability in Cumulus to specify the location of the realtime.txt file? So instead of saving it to C:\CumulusMX, saving it somewhere else (as in the wwwroot)?
You can add it to the extra web files, and specify the current and required locations (including the actual file name), tick 'realtime', but not 'ftp' or 'process'. It will then copy the file each time.

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Thu 30 Jun 2016 11:24 pm
by stefanbagnato
Awesome! That works. I had written a batch file to copy the file over every minute. But this is easier. The other I was having that I am currently working on is that I set a scheduled task in Server 2012 to run the http://localhost/update/cumulus.php?pass=XXXXXXX to run every minute, as the steps Jachym wrote say. But, when mine would run, a pop-up comes up:

How do you want to open this type of link (http)?
Keep using Internet Explorer

Obviously my default browser is IE. The only want I have found around it so far is to write a script to open IE and then run the task.

START "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://localhost/update/cumulus.php?pass=XXXXX"

The issue with that is that it keeps opening more instances of IE and not using the same one. I am working on a script to kill off that instance (so I can keep Cumulus running in a separate window) that kills it by the window title name, it just is not working yet...

@echo off
timeout /t 3
taskkill /FI "WINDOWTITLE eq localhost*"


****UPDATE****

I got that script to work now. Still seems odd that I have to use it though. Anybody else on a Windows platform have that default programs problem??
exit

****UPDATE #2****

So I decided to see if it was just the cumulus.php causing that IE prompt, or all. I ran the script with install/setup.php, and same thing. So, that rules out any issue with the specific script. Same question though; does anybody else on a Windows platform have the default programs problem?

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Fri 01 Jul 2016 1:36 am
by PaulMy
I use https://www.cron-job.org/en/ for /update/cumulus.php?password=xxxxx

Meteotemplate and IE are not a good mix. If you are having problems try another browser.

Paul

Re: Meteotemplate cron job for Cumulus realtime.txt

Posted: Mon 04 Jul 2016 10:26 am
by mcrossley
I may be missing something here (reading this on my phone), but if your web server and scheduled task are on the same machine, why are you messing around with calling http URLs?

Just call the PHP script directly, with <pathtophp>PHP.exe <pathtoscript>script name.php <scriptparams>

The format for passing the parameters changes slightly for the CLI from URL, but it is a much neater approach. It is how I did it on my old windows server, and via a cron job on the rPi.

In the old CumulusSQL script the header gives instructions for calling it via a URL or CLI.