Re: Cron is sorting with ls differently



spacemancw wrote:
On Mar 30, 9:51 pm, Bill Marcum <marcumb...@xxxxxxxxxxxxx> wrote:
On 2008-03-31, spacemancw <spacema...@xxxxxxxxx> wrote:





I am running a script in cron and it is does an 'ls' differently than
when I run the script in my shell at the command line. I ran a quick
experimen to see how cron sorts file with ls ( I also tried ls -x).
I made a folder with these files
afile Afile bfile Bfile cfile Cfile
When I run my script at the command line, they get sorted
alphabetically, the way I want it, as follows
afile Afile bfile Bfile cfile Cfile
When the script runs in cron the files are sorted as follows
Afile Bfile Cfile afile bfile cfile
I tried add /home/myuser/.cshrc to the first line of my shell but no
luck
Did you source .cshrc? Otherwise, any variables set in there would be
lost. The variable you need to set is LANG or LC_COLLATE.- Hide quoted text -

- Show quoted text -


Thanx

wheb I type locale at my comman line I get

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

so am I supposed to load this under cron?
I added all these lines to the top of my script but it didn't make a
difference

thanx


You must export these variables.
In your script, you need to export these variables.

Alternatively you can just replace
ls
by
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 ls

--
Michael Tosch @ hp : com
.



Relevant Pages

  • Re: Cron is sorting with ls differently
    ... I am running a script in cron and it is does an 'ls' differently than ... afile Afile bfile Bfile cfile Cfile ...
    (comp.unix.shell)
  • Cron is sorting with ls differently
    ... I am running a script in cron and it is does an 'ls' differently than ... afile Afile bfile Bfile cfile Cfile ...
    (comp.unix.shell)
  • SUMMARY: cron entry: nth day of every month?
    ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
    (Tru64-UNIX-Managers)
  • Re: Cron Jobs
    ... > having a cron will mean yo server is forced by the script ... > best than allowing mail dequeing by connection. ... > host server so I can get emails for my domain example.com. ...
    (RedHat)
  • Re: Problems with periodic scripts in jails [Cron <operator@sosai> /usr/libexec/save-entropy]
    ... >> If a cron job (eg, a shell script) doesn't perform whatever locking it ... it's not difficult to imagine cron kicking off the script ... > That's a good suggestion. ...
    (freebsd-current)