I am brand new to module development, fresh off the D7 tutorial boat. What I want to do cannot be that hard.
I have created my first module called get_weather, with get_weather.info and get_weather.module properly installed and drupal recognized.
I created another simple script that has one function, which I want to run when cron runs. 'update_weather' the ONLY thing this does is return the temperature for that time and store it in the database.
There is nothing to display, there are no blocks to render. However, this does not work:
function get_weather_cron() { update_weather(); }
What's going on here? I get no errors, but nothing happens at all? How do I get my module to run my custom function when cron runs?
Note that my custom function works fine if I run it from a script outside of a Drupal module environment.
Here is code based on comments feedback:
include('weather.php');
function get_weather_cron(){
watchdog('get_weather_debug', 'Cron function triggered');
update_weather();
}
Also here is update_weather, which is included in the weather.php include file:
function update_weather() {
$page['weather'] = scrape_weather();
//insert into db code here;
}
Again, when I simply run this php normally outside of the drupal enviroment, everything works fine. All I want to do is run this same script when cron runs so this is done automatically. No function in my entire library for this functionality has anything to do with Drupal. I am simply trying to activate it by using cron.
hook_cron()
?