CRON is changing encoding?

Solution 1:

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.

Solution 2:

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:

LANG=de_DE.UTF-8
LANGUAGE=de
LC_CTYPE=de_DE.UTF-8
PYTHONIOENCODING=utf8

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.