I have a legacy Java program that outputs an SQL script. I then use Apache Derby to run that SQL on the target database (which is not on the same server as CRON).

When run via putty, this works fine. When run in windows this works fine. When run using CRON, Derby reads £ signs as ?.

If I look at the sql script generated (using VI), it contains the £ signs. If I check the database however, it contains ?.

Why would running this under CRON make the program behave any differently?


It appears that CRON was the issue. When the Java program ran, and outputted the results to file, it failed to write correctly. The SQL file I was reading was pointing at a wrong version.

To solve the problem, I added the following code near the top of the CRON script

export LANG = en_US.UTF-8

This ensured that the £ sign was correctly formatted.

  • You can also accept your own answers (clicking on the tick in the circle left to your answer). :) – htorque Nov 12 '10 at 5:16

for me, the mentioned solutions weren't working. another solution i read was to set

"LANG=en_US.UTF-8" in the "/etc/environment" file.

But wasn't working neither.

What was working for me was to open the crontab file with

crontab -e

and set at the beginning:


Which also sets the environment variable.

This must be done with every user you want to run these variables. For root run "sudo -s" before entering crontab.

Not the answer you're looking for? Browse other questions tagged or ask your own question.