cron and POSIX - Slackware

This is a discussion on cron and POSIX - Slackware ; I try to run from cron a script: /usr/bin/rsync -agEvz --delete-after /home/damir/Desktop/ \ /home/damir/.smb/shares/mynet/NET/public/backup \ s/damir/ > /home/damir/output.rsync 2>&1 rm -f /tmp/locale /usr/bin/locale > /tmp/locale cat /tmp/locale LANG= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" LC_ADDRESS="POSIX" LC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: cron and POSIX

  1. cron and POSIX

    I try to run from cron a script:
    /usr/bin/rsync -agEvz --delete-after /home/damir/Desktop/ \
    /home/damir/.smb/shares/mynet/NET/public/backup \
    s/damir/ > /home/damir/output.rsync 2>&1
    rm -f /tmp/locale
    /usr/bin/locale > /tmp/locale

    cat /tmp/locale
    LANG=
    LC_CTYPE="POSIX"
    LC_NUMERIC="POSIX"
    LC_TIME="POSIX"
    LC_COLLATE="POSIX"
    LC_MONETARY="POSIX"
    LC_MESSAGES="POSIX"
    LC_PAPER="POSIX"
    LC_NAME="POSIX"
    LC_ADDRESS="POSIX"
    LC_TELEPHONE="POSIX"
    LC_MEASUREMENT="POSIX"
    LC_IDENTIFICATION="POSIX"
    LC_ALL=

    I use in my systems (in /etc/profile.d/lang.sh(csh) ru_RU.UTF8 -- russian
    locale), why when I run script from cron locale changed on POSIX and where
    I can change such behaviour? File output.rsync contain garbage (for
    example \#320\#230\#320\#267\#320\#276\#320\#261\#321) in those places
    where there is cyrillics. If I run script from user or root all ok.

    p.s. I know that it is possible to use iconv, but it would be desirable
    more correct way.

    --
    Murat D. Kadirov

  2. Re: cron and POSIX

    Murat D. Kadirov wrote:
    > I try to run from cron a script:
    > /usr/bin/rsync -agEvz --delete-after /home/damir/Desktop/ \
    > /home/damir/.smb/shares/mynet/NET/public/backup \
    > s/damir/ > /home/damir/output.rsync 2>&1
    > rm -f /tmp/locale
    > /usr/bin/locale > /tmp/locale
    >
    > cat /tmp/locale
    > LANG=
    > LC_CTYPE="POSIX"
    > LC_NUMERIC="POSIX"
    > LC_TIME="POSIX"
    > LC_COLLATE="POSIX"
    > LC_MONETARY="POSIX"
    > LC_MESSAGES="POSIX"
    > LC_PAPER="POSIX"
    > LC_NAME="POSIX"
    > LC_ADDRESS="POSIX"
    > LC_TELEPHONE="POSIX"
    > LC_MEASUREMENT="POSIX"
    > LC_IDENTIFICATION="POSIX"
    > LC_ALL=


    These "POSIX" values seem to be the defaults when "LANG" is not defined
    in the environment and the LC_* variable are also undefined.

    Try for instance in an interactive shell:
    /usr/bin/locale
    unset LANG
    /usr/bin/locale

    >
    > I use in my systems (in /etc/profile.d/lang.sh(csh) ru_RU.UTF8 -- russian
    > locale), why when I run script from cron locale changed on POSIX and where
    > I can change such behaviour? File output.rsync contain garbage (for
    > example \#320\#230\#320\#267\#320\#276\#320\#261\#321) in those places
    > where there is cyrillics. If I run script from user or root all ok.
    >
    > p.s. I know that it is possible to use iconv, but it would be desirable
    > more correct way.
    >


    Just put as the first commands in your script:
    LANG=ru_RU.UTF8
    export LANG

    And have a look at the following quote from the crontab(1) manpage:
    Unlike other crond/crontabs, this crontab does not try to do
    everything under the sun. Frankly, a shell script is much more able
    to manipulate the environment then cron and I see no particular
    reason to use the user's shell (from his password entry) to run
    cron commands when this requires special casing of non-user crontabs,
    such as those for UUCP.
    When a crontab command is run, this crontab runs it with /bin/sh
    and sets up only three environment variables: USER, HOME, and SHELL.



    Regards,

    Kees.

    --
    Kees Theunissen.




+ Reply to Thread