Score:1

When I execute a script in crontab the output is in a different language

in flag

I am executing a script in a crontab that writes a log, when I run it as root, the log is written in spanish.

But when I run it in the crontab, the output is in english.

Is there a way to run the crontab with the same configuration I do when I run it as root?

in flag
Set the proper `LC_*` variables.
in flag
Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it)
aldegalan avatar
in flag
I can not identify my problem there... Could you please provide me an example? @GeraldSchneider
in flag
The problem is that the `LC_*` variables are unset. How to set them in cron is described in the linked question.
flowtron avatar
cn flag
Not directly. I decided to write a concrete answer, but mention the general panacea answer and you originally posting it.
Score:1
cn flag

You have two possible solutions; you could write a wrapper script that sets the appropriate enviroment variables and then calls your original cron script. If you want the LANG - which is what I expect you need to set - to be the same for all scripts you just define it at the top of your crontab. This is explained in the answer Gerald Schneider linked Why is my crontab not working, and how can I troubleshoot it? but not explicitely for LC_* or LANG. Here's how to do it:

LANG=es_ES
*/15 */2 3 * * /opt/jobs/repeat-this.sh

Depending on what your script does you may need to set specifc LC_* values; or simply set LC_ALL=es_ES.

LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, LC_IDENTIFICATION, LC_ALL

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.