cron and POSIX

This is a discussion on cron and POSIX within the Slackware forums, part of the Help category; 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" ...

Go Back   Unix Linux Forum > Unix > Linux > Help > Slackware

FixUnix.com - Unix Linux Forums

Unix Content Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-24-2008, 07:22 PM
Default 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
Reply With Quote
  #2  
Old 08-24-2008, 07:55 PM
Default 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 With Quote
Reply

Thread Tools


All times are GMT -5. The time now is 01:03 PM.

In an effort to better serve ads to our visitors, cookies are used on Fixunix.com. For more information, check out our Privacy Policy.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Ad Management by RedTyger