1

Which ENV must be exported that a bash cronjob script opens the program in the correct language?

If I open the bash script so manually in the command-line the program is opened in the correct language.

However, if the program is opened via the cronjob, the program runs via the wrong language?

The LANG ENV can not be I checked that is also in the Crontab on the same language.

thanks in advance.

1

TL;DR You need to set LC_ALL or LC_MESSAGES. For example:

LC_ALL=en_US.utf8

The list of all supported locales from your machine can be obtained with: locale -a and locale -av for more details.

Details

From crontab(5) man page (man -S5 crontab):

An active line in a crontab is either an environment setting or a cron command. An environment setting is of the form:

name = value

By default, cron sends a mail using the Content-Type: header of text/plain with the charset= parameter set to the charmap/codeset of the locale in which crond(8) is started up, i.e., either the default system locale, if no LC_* environment variables are set, or the locale specified by the LC_* environment variables (see locale(7)). Different character encodings can be used for mailing cron job outputs by setting the CONTENT_TYPE and CONTENT_TRANSFER_ENCODING variables in a crontab to the correct values of the mail headers of those names.

From locale(7) man page (man -S7 locale):

LC_MESSAGES
This category affects the language in which messages are displayed and what an affirmative or negative answer looks like. The GNU C library contains the gettext(3), ngettext(3), and rpmatch(3) functions to ease the use of this information. The GNU gettext family of functions also obey the environment variable LANGUAGE (containing a colon-separated list of locales) if the category is set to a valid locale other than C. This category also affects the behavior of catopen(3).

LC_ALL
All of the above.

To troubleshoot the environment of a process, you can display it with the following command. Replace <PID> with the process id of your cron job that is still running. You will need to test with a cronjob that takes a few minutes at least (e.g. sleep 300).

ps e -wwp <PID>
2
  • Works thanks :) – Omexlu May 15 at 12:41
  • 1
    Happy to help. Thank you for the points. – Mircea Vutcovici May 15 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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