Why does cron email me the contents of my script rather than running it?
I have a requirement to import a CSV into a mysql database on a daily basis. The CSV will be on the web server in a directory.
This is the PHP script (named invoicedataimport.php) that I have at the moment:
#!/bin/bash
DB_USER='company_reports';
DB_PASSWD='companypassword';
DB_NAME='company_reports';
TABLE='Invoices';
INPUT_FILE='/home3/company/companyreport/invoices/*.csv';
SQL="USE $DB_NAME; LOAD LOCAL DATA INFILE '$INPUT_FILE' REPLACE INTO TABLE `$TABLE` LINES TERMINATED BY ',' CHARACTER SET utf8;"
mysql --user=$DB_USER --password=$DB_PASSWD --default_character_set utf8 $DB_NAME -e "$SQL"
The reason I have used *.csv above rather than an absolute filename is that each day the CSV file will have a date stamp in the filename.
Once I have gotten the above to work - I need to figure out how to set up another cron to move all CSV files from that directory to another "Archive" directory.
I have setup a cron job - I'm not sure if I have done this right:
15 16 * * * /usr/bin/php /home3/company/companyreport/crons/invoicedataimport.php
When the time passes - I receive an email notification from my server with just the contents of the PHP file?
链接地址: http://www.djcxy.com/p/66350.html上一篇: 8)用Python读写文件