[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Sheflug] Help with non-functioning cron job
I've got a cron job that pulls data into an mySQL database. The cron job
simply executes a script. The script works fine if I run it from a bash
shell, but if I move the script over to cron, I think it starts to execute,
but never seems to do anything. I know it starts because the line in the
crontab says:
05 13 * * * /david/database/getdata.smb > /tmp/databaseimport.log
...and /tmp/databaseimport.log is being updated.
The pertinent bits of the script are below. It's failing early on because
the file times on the /tmp/*.cvs files are wrong - i.e. they're not todays,
but the /tmp/databseimport.log file has the correct date and time on it. The
only idea I had was that the mySQL user was incorrect, but it doens't look
as if it's getting that far. I've just amended the script to include fully
qualified file names for the smbclient and mysql executables to no avail.
Any suggestions are welcome. FWIW, Vixie cron on a 2.2.13 SuSE 6.3 kernel
(yeah - old, I know, but it works and it's scheduled for replacement soon).
[script follows]
/usr/bin/smbclient //picsserverffr/f -U****%**** <<EOF
get ppcad.csv /tmp/ppcad.csv
get ppctrop.csv /tmp/ppctrop.csv
get ppctrmach.csv /tmp/ppctrmach.csv
get ppctravheader.csv /tmp/ppctravheader.csv
get ppctravlines.csv /tmp/ppctravlines.csv
get ppcdept.csv /tmp/ppcdept.csv
EOF
/usr/local/mysql/mysql -p****** <<EOF1
use ppcdata;
delete from traveller_header;
load data infile '/tmp/ppctravheader.csv' into table traveller_header
fields terminated by ','
lines terminated by '\r\n'
(ordernum,serial,reqweek,holdcode,location,prodalert,complete)
;
delete from traveller_detail;
load data infile '/tmp/ppctravlines.csv' into table traveller_detail
fields terminated by ','
lines terminated by '\r\n'
(ordernum,serial,stepnumber,department,operation,millinst,
expectweight,opstarted,opstartdate,targetdate,bookdate,
chargeweight,producedweight)
;
[snip]
delete from operation_codes;
load data infile '/tmp/ppctrop.csv' into table operation_codes
fields terminated by ','
lines terminated by '\r\n'
(operation,description)
;
EOF1
--
David Morris
European IT Manager, ALLVAC Ltd
email work: david [at] allvac.co.uk home: david [at] brassedoff.net
http://www.davidm.demon.co.uk
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.