codeable
asked on
cron unzip insert into mysql
I'm hoping somebody can help. I need to set up a cron to unzip csv fils and insert into mysql. The details aren't important just a good starting point would be great. I'm working with Linux Apache Red Hat. Thank you in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect. Even though my question wasn't clear. This was close to what I was looking for. Thanks.
Just make sure you get proper load data query ready and rest seems easy
Write shell script::
vi loadData.sh
mysql -uUSER -pPASSWORD -e "LOAD DATA LOCAL INFILE 'path/to/file.csv' INTO TABLE example FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 LINES ;"
Crontab -e
x x * * * sh /path/to/loadData.sh
Below shall help::
http://kedar.nitty-witty.com/blog/load-delimited-data-csv-excel-into-mysql-server/
http://kedar.nitty-witty.com/blog/mysql-load-data-infile-syntax-generator-tool/
Write shell script::
vi loadData.sh
mysql -uUSER -pPASSWORD -e "LOAD DATA LOCAL INFILE 'path/to/file.csv' INTO TABLE example FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 LINES ;"
Crontab -e
x x * * * sh /path/to/loadData.sh
Below shall help::
http://kedar.nitty-witty.com/blog/load-delimited-data-csv-excel-into-mysql-server/
http://kedar.nitty-witty.com/blog/mysql-load-data-infile-syntax-generator-tool/
ref. https://www.experts-exchange.com/questions/23965839/PHP-Cron-exec-command-not-found.html