The impact of language settings on cron after upgrading SLES11 SP4 to SLES12 GA~SP5

This document (000020816) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 12 All Releases
SUSE Linux Enterprise Server for SAP Applications 12 All Releases

Situation

After upgrading from SUSE Linux Enterpise Server 11 SP4 to SUSE Linux Enterprise Server 12  GA ~ SP5,When the application program sets Chinese or special characters, garbled characters may appear when cron calls the application.

A test script shows the how the issue is reproduced on both SLES11 SP4 and SLES12 SP5. The test script creates its output in /tmp/cron.txt.
# cat /root/test.sh
#! /bin/bash
LOGFILE=/tmp/cron.txt
/usr/bin/locale | egrep "LANG|LC_CTYPE|LC_ALL" > $LOGFILE
export LANG=zh_CN.utf8
echo "results after setting LANG:" >> $LOGFILE
/usr/bin/locale | egrep "LANG|LC_CTYPE|LC_ALL" >> $LOGFILE
On SLES11 SP4:
sles11sp4:~ # crontab -l
* * * * * /root/test.sh

sles11sp4:~ # strings /proc/`pidof cron`/environ | grep LC_
LC_ALL=POSIX

sles11sp4:~ # cat /tmp/cron.txt
LANG=
LC_CTYPE="POSIX"
LC_ALL=
results after setting LANG:
LANG=zh_CN.utf8
LC_CTYPE="zh_CN.utf8"
LC_ALL=
It can be seen that on SLES11 SP4, LC_ALL is set to POSIX in the cron process environment, but the cron task does not inherit LC_ALL or load it. Setting LANG in the cron task affects both LANG and LC_CTYPE.

On SLES12 SP5:
sles12sp5:~ # crontab -l
* * * * * /root/test.sh

sles12sp5:~ # strings /proc/`pidof cron`/environ|grep LC_ 
LC_CTYPE=en_US

sles12sp5:~ # cat /tmp/cron.txt
LANG=
LC_CTYPE=en_US
LC_ALL=
results after setting LANG:
LANG=zh_CN.utf8
LC_CTYPE=en_US
LC_ALL=
It can be seen that on SLES12 SP5, LC_CTPYE is set to en_US in the cron process environment. LC_CTYPE is inherited and loaded in the cron task. Setting LANG in the cron task only affects LANG, LC_CTYPE is unchanged.

Resolution

It is recommended to set LC_CTYPE or LC_ALL in the application.

Cause

After upgrading SUSE Linux Enterpise Server 11 SP4 to SUSE Linux Enterprise Server 12  GA ~ SP5, when the application program called by the cron task uses Chinese or special characters, you can not only set LANG, but also set LC_CTYPE or directly set LC_ALL.

SUSE Linux Enterprise Server 11 SP4 provides a cron package based on vixie-cron. The env_set  from vixie-cron package does not contain env_set_from_environ. The child process of the cron daemon fork will not inherit any environment variables. The setting of all character-related environment variables requires the command called by the cron task or the application-specific loading. If not set, it will be empty.

SUSE Linux Enterprise Server 12 GA ~ 12 SP5 provide a cron package based on cronie. The env_set from cronie package contains env_set_from_environ. This is a difference in software design. The child process of the cron daemon fork will inherit the current character environment variables, including LC_CTYPE here. Therefore, when the command or application called by the cron task does not set LC_CTYPE, the value of the cron daemon will continue and will not be empty.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020816
  • Creation Date: 20-Oct-2022
  • Modified Date:01-Nov-2022
    • SUSE Linux Enterprise Server
    • SUSE Linux Enterprise Server for SAP Applications

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center