Link to home
Start Free TrialLog in
Avatar of codeable
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
Avatar of Om Prakash
Om Prakash
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Loganathan Natarajan
You have to write script to unzip the csv and insert into Mysql... then you can make the script to cron.

ref. https://www.experts-exchange.com/questions/23965839/PHP-Cron-exec-command-not-found.html
Avatar of codeable
codeable

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/