The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running command "top" in cron freddy1228 UNIX for Dummies Questions & Answers 3 03-18-2008 12:43 PM
How to display hostname in command prompt civic2005 SUN Solaris 3 10-12-2007 06:42 AM
Inconsistent memory usage display spdas Filesystems, Disks and Memory 2 02-15-2007 09:15 PM
PS command does not display shell script running hadarot Shell Programming and Scripting 4 09-15-2005 02:56 AM
Running "wall" command from cron xadamz23 Shell Programming and Scripting 1 05-27-2005 05:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-30-2007
Registered User
 

Join Date: Sep 2005
Posts: 5
inconsistent ls command display at the command prompt & running as a cron job

Sir,
I using the following commands in a file (part of a bigger script):
#!/bin/bash
cd /opt/oracle/bin
ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out

If I run this from the command prompt the result is:

2007-05-16

if I run it as a cron job then I get:

May

In both cases I need to get:

2007-05-16
Can any help with this?


Thanks in advance.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-30-2007
Registered User
 

Join Date: Jun 2006
Posts: 74
Which OS you are using. I tried the same command in AIX

ls -lt | tail -1 | awk '{print $6}'

and I got 'Jul' as response
Reply With Quote
  #3 (permalink)  
Old 07-30-2007
Registered User
 

Join Date: Sep 2005
Posts: 5
We are using suse enterprize 9
Linux 2.6.5-7.283-smp #1 SMP Wed Nov 29 16:55:53 UTC 2006 x86_64 x86_64 x86_64 GNU/Linu
Reply With Quote
  #4 (permalink)  
Old 07-30-2007
Registered User
 

Join Date: Jun 2006
Posts: 74
I am not sure..

try executing the command with full path


/bin/ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out
Reply With Quote
  #5 (permalink)  
Old 07-30-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
/bin/ls -lt --time-style=locale | ...

Cheers,
ZB
Reply With Quote
  #6 (permalink)  
Old 07-30-2007
Registered User
 

Join Date: Sep 2005
Posts: 5
Thanks for all the suggestions and a solution.

time-style= long-iso or time-style=+%Y-%m-%d will do us nicely.

Once again thanks.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0