Different time format in script, started in shell or in cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Different time format in script, started in shell or in cron
# 1  
Old 04-19-2009
Tools Different time format in script, started in shell or in cron

I try to write a python script, which analyze user logon time with "who" command.
When i start script in bash, i get this result:
USER=mnadmin tty7 2009-04-18 11:37 (:0)
But when i start script in cron, i get result like this:
USER=mnadmin tty7 Apr 18 11:37 (:0)

I see - script have different environment in both cases, but i dont know where is time format defined...
I want to get a time format like i get it in bash.
Any ideas?
# 2  
Old 04-19-2009
Take a look at en environment variables LANG, LC_ALL, LC_TIME
# 3  
Old 04-19-2009
Quote:
Originally Posted by pludi
Take a look at en environment variables LANG, LC_ALL, LC_TIME
Yes! It is !
I add environment variable inside my script:
os.environ["LANG"]="en_US.UTF-8"
and now the time is in right format:
USER=mnadmin tty7 2009-04-19 12:04 (:0)

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check whether shell script has started.

How can i ceck as shellscript, if a other shellscript has been started? The other script can bee started by a other user. The task will not run twice (5 Replies)
Discussion started by: Linuxmann
5 Replies

2. OS X (Apple)

[OS X] Last modification time from shell in CCYYMMDDhhmm.ss format

This example shows last mtime from epoch $ stat -f %m somefile 752911565 But would like to see it like that: 199311100606.05 (2 Replies)
Discussion started by: Tribe
2 Replies

3. Shell Programming and Scripting

How to get cron (scripts in crontab) started?

Hi, I have a query related to UNIX Crontab scripts - Issue: Server space on the db server got 100% full as a result of which the cron scripts did not run. The space utilization issue got resolved in the afternoon. The crons scheduled for a time post the resolution caught up. However the... (1 Reply)
Discussion started by: qwerty000
1 Replies

4. Shell Programming and Scripting

Cron tab time generation script

Hi folks, Everyone knows about crontab, what i am looking for a script where i will define hour,minute and day and it will generate crontab complete time entry, i have seen many website generating crontab entry and my question is that is there any shell script that can do same work. 20 09... (4 Replies)
Discussion started by: learnbash
4 Replies

5. Shell Programming and Scripting

get system date, format it, pass it as a parameter to a perl script - all in cron job

I am trying to get the string containing date - in a specfic format actually, although I think that part is inconsequencial - 1110226^1110226^1110226^1110226^1110226 - through echo or printf or in some other way - created within a cront job and passed as a parameter to a perl script. Now, I know... (3 Replies)
Discussion started by: v8625
3 Replies

6. Shell Programming and Scripting

Time elapsed since script started

Hi I want to know if there is anyway I can find out how long it has been since I started my script or total time it has been since my script is executing. Idea here is I want to check if my script is taking more than 30minutes to execute I want to kill that process. Thanks in advance. (1 Reply)
Discussion started by: dashing201
1 Replies

7. Shell Programming and Scripting

help for a script to increment time in hh:mm:ss format

hi all, I need help for incrementing time in hh:mm:ss format like for example : when i have a values like 02:07:16 I want to increment this value with 5 secs till it reaches a condition. Can someone help me with this. Thanks in advance. (2 Replies)
Discussion started by: hitha87
2 Replies

8. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

9. Shell Programming and Scripting

Cron time format

Hi, i would like to ask if this cron is valid. 40 3-6,8-23 * * * /my command i want my job to run every hour on the 40th minute except 740am. Is this correct? (1 Reply)
Discussion started by: new2ss
1 Replies

10. Shell Programming and Scripting

Script to run 100jobs at a time from cron

here is my requirement. When ever the customer visitis the sore we want to look his information by his phone no. From the database side we are putting all the information in session pools. for example if we have 500 stores and at any second one customer is at the counter we can get atlease 500... (2 Replies)
Discussion started by: skneeli
2 Replies
Login or Register to Ask a Question