date format on lpstat output
Helge Blischke
h.blischke at srz.de
Wed Aug 29 05:21:04 PDT 2007
Amy Tanner wrote:
>>Amy Tanner wrote:
>>
>>
>>>I'm having a problem with a cron job I'm running. I narrowed it down
>>>to the fact that when I run lpstat -o as root, the date/time column
>>>is in a different format than when the job is run from cron.
>>
>>Which are the two formats?
>>
>>Can you post examples?
>
>
> When run as me:
>
> printer7-9 atanner 15360 Tue 19 Jun 2007 03:07:48 PM CDT
>
>
> When run as root:
>
> printer7-9 atanner 15360 Tue Jun 19 15:07:48 2007
>
>
>>Which is the output of your "locale" command?
>>
>>Is it different for a user and for root?
>
>
> Yes it is:
>
> me:
>
> $ locale
> 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=
>
>
> root:
> # locale
> LANG=POSIX
> LC_CTYPE=en_US.UTF-8
> 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=
>
>
>>Which is the user that your cron job script is running as?
>
>
> runs as root
>
>>>Is there
>>>some environment variable lpstat is using to determine in which format
>>>to output that date/time column.
>>
>>You can experiment with setting the LANG, LC_TIME and/or LC_ALL env
>>variables on the commandline:
>>
>> LC_TIME="C" lpstat -W completed | tail
>> LC_TIME="en_US" lpstat -W completed | tail
>> LC_TIME="de_DE.UTF-8" lpstat -W completed | tail
>> [....]
>>
>>Once you find the output that you like, put that variable into your
>>cron job script.
>
>
> Yes, that worked. I figured there was something like that causing it, but I just couldn't find it. Thanks for helping me solve this mystery.
>
>
I usually set all this locale stuff to C or POSIX whenever
interpreting timestamps etc. by program. This way
I completely avoid fiddling around with different
formats when programming.
Helge
--
Helge Blischke
Softwareentwicklung
H.Blischke at acm.org
More information about the cups
mailing list