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
This ensured that the £ sign was correctly formatted.
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
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.