[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: AW: AW: [cobalt-users] Problems with cronjob



Axel,

On Monday 22 April 2002 04:02 pm, Axel Denk wrote:
> Hi Eddy,
>
> thanks for you answer, I already added the shell script 2 days ago. Do
> express myself very clearly; I try to explain it again to hopefully get
> help to solve the problem. :-)
>
> (1) I have two files now:
>
> [admin cron.daily]$ ls -all test.*
> -rwxr-xr-x   1 root     root           96 Apr 21 23:12 test.cron
> -rwxr-xr-x   1 root     root          261 Apr  7 18:11 test.sql
>
> (2) test.cron looks like that:
>
> [admin cron.daily]$ cat test.cron
> #!/bin/sh
> /usr/bin/mysql --user=test --pass=test < /etc/cron.daily/test.sql
> admin cron.daily]$
>
> (3) test.sql looks like that:
>
> [admin cron.daily]$ cat test.sql
> connect test_info
> DELETE FROM testProducts;
> LOAD DATA LOCAL INFILE
> '/home/sites/www.test.de/users/testuser/test.csv'
> REPLACE INTO TABLE testProducts FIELDS
> TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY
> '\n'
> \g
> \q
> [admin cron.daily]$
>
> (4) When I connect to the shell, I can execute the script by typing:
>
> /etc/cron.daily/test.cron
>
> With ssh, the script runs perfect. It accesses the .sql file, executes
> the sql commands and updates my table.
>
> (5) Because the script runs as it is in the shell, I just leave it in
> the cron.daily folder. Unfortunately, when the cronjob tries to run the
> script, I get the following error message:
>
> /etc/cron.daily/test.sql: connect: command not found
> /etc/cron.daily/test.sql: DELETE: command not found
> /etc/cron.daily/test.sql: LOAD: command not found
> /etc/cron.daily/test.sql:
> /home/sites/www.testr.de/users/testuser/test.csv: Permission denied
> /etc/cron.daily/test.sql: REPLACE: command not found
> /etc/cron.daily/test.sql: TERMINATED: command not found
> /etc/cron.daily/test.sql: g: command not found
> /etc/cron.daily/test.sql: q: command not found
>
> => So I think it is not a problem of the files itself, it just can not
> interpret the test.sql as sql commands. Instead it thinks these commands
> are shell commands. I read in the crontab man, but didn't find any
> hints.
>
> So I would really appreciate if someone can give me more tips. Even if
> you only have an idea, I would be very thankful. Maybe the hints can
> solve my problems.
>
> Thank you very much again for all your help
>
> Axel Denk
> Denk IT GmbH

  The solution is actually quite simple.  The problem is that "cron" attempts 
to "run" _every_ file in the cron.daily folder.

  Simply move the sql script (file test.sql) to _another_ directory (not 
under cron - for example /home/sites/home/logs/test.sql), then correct the 
test.cron script to read the correct path (/home/sites/home/logs/test.sql) 
and it should work fine.

Larry Smith
SysAd ECSIS.NET
sysad@xxxxxxxxx