1

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?

aldegalan
  • 33
  • 5

1 Answers1

1

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

flowtron
  • 215
  • 2
  • 5