Execute a function every hour in the background
I'm in kind of a weird situation (for me)
My client has a website that runs on a custom CMS
He wants an online site that loads some data from the existing database.
This is an external MSSQL database and for security reasons a serialized table is created.
So there is no way for me to "read" from the database.
I contacted the company that hosts and maintains the database and they said that they could automatically create an .csv
export for me every hour and save it at a location on the server.
So I was very happy with this because this is a comma seperated .csv
file.
I learned that I could import this to my WP MySQL database with the following:
LOAD DATA INFILE '../tmp/file.csv'
INTO TABLE $table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
So far so good. But now my headache starts. I want to do this every hour. So that if their database is altered mine get's updated. The file may overwrite every table/field in the database. (I only use it for reading)
I know I can create a cronjob to do this. I simply don't know where to do this. This task must run every hour. So this does not go in a function.php file or even a template.php file.
Come to think about it, maybe it shouldn't even be done in WordPress core/custom files.
However. Because I don't know where to initiate the function I can not update my database.
Hope somebody has a (alternative) solution.
M.