Can someone help me to convert the date format after get it from the "LAST REBOOT" command.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can someone help me to convert the date format after get it from the "LAST REBOOT" command.
# 1  
Old 08-13-2010
Hammer & Screwdriver Can someone help me to convert the date format after get it from the "LAST REBOOT" command.

Can someone help me to convert the date format after get it from the "LAST REBOOT" command.

these is the standard output.
bash-3.00# last reboot
reboot system boot Fri Aug 6 15:07
reboot system down Fri Aug 6 15:04
reboot system boot Wed Jul 14 16:12
reboot system down Tue Jul 6 20:04
reboot system boot Tue Jul 6 19:59
reboot system down Fri May 7 10:22
reboot system boot Fri May 7 10:01
wtmp begins Fri May 7 10:01
bash-3.00#

But.. I want
reboot system boot 2010-08-06 15:07
reboot system down 2010-08-06 15:04
reboot system boot 2010-08-06 16:12
reboot system down 2010-08-06 20:04
reboot system boot 2010-08-05 19:59
reboot system down 2010-08-05 10:22
reboot system boot 2010-08-06 10:01

Is it posible?
# 2  
Old 08-13-2010
check the faq article: https://www.unix.com/answers-frequent...rithmetic.html

should find what you're after
or use the search functionality...

trying "date conversion" brought up many hits including

https://www.unix.com/unix-dummies-que...onversion.html

Enjoy ;-)
This User Gave Thanks to Tytalus For This Post:
# 3  
Old 08-16-2010
Hammer & Screwdriver

Thank you for reply, Tytalus

Actually i have researched the fucntion date and it is workable, but my problem in this acticle is converting the date when call the last reboot command.
when I execute the "last reboot > last_reboot.txt" it is plain text. there are no YEAR in the text, so I cannot connvert the plain text without YEAR.


the data in the plain text
reboot system boot Fri Aug 6 15:07
reboot system down Fri Aug 6 15:04
reboot system boot Wed Jul 14 16:12
reboot system down Tue Jul 6 20:04
reboot system boot Tue Jul 6 19:59
reboot system down Fri May 7 10:22
reboot system boot Fri May 7 10:01
wtmp begins Fri May 7 10:01
# 4  
Old 08-18-2010
My question have resolved. my partner sent this URL to me. It can help someone who needs the output like me. Smilie

General Solaris 10 Discussion - Unix last command does not dispay year
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Convert "hex" foldername to "ascii"

So, I have a folder, containing subdirs like this: 52334d50 52365245 524b4450 524f3350 52533950 52535050 52555550 now I want to go ahead and rename all those folder: hex -> ascii (8 Replies)
Discussion started by: pasc
8 Replies

2. Solaris

Changing "rx_queue_number" in "ixgbe.conf". Reboot or Network Restart?

Hi all, First post here. Working on Solaris 10, on a Sun t4-4, need to change RX queue depth(ethernet, not HBA) and was wondering if i could get by with just restarting the network or if i should just bounce the whole shebang. Apologies if i missed a similar thread. if there is one, please... (2 Replies)
Discussion started by: caspnx
2 Replies

3. Shell Programming and Scripting

awk "date" and "system" command

Hello experts! I need your help please I have a file.txt of which I want to extract 3rd and 4th columns with date with the form e.g.: 2016-11-25 03:14:50and pass them to "date" command, but also append the 9th column in a file as well. So I want to execute date -d '2016-11-25 03:14:50' ... (2 Replies)
Discussion started by: phaethon
2 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Format output from the file to extract "date" section

Hello Team , I have to extract date section from the below file output. The output of the file is as shown below. I have to extract the "" this section from the above output of the file. can anyone please let me know how can we acheive this? (4 Replies)
Discussion started by: coolguyamy
4 Replies

8. UNIX for Dummies Questions & Answers

converting date format: "May 31 2008" to "2008-05-31"

I have the following script to find out the last day of the last month .... and the output of this script is in the following format ... Script goes like this .... #!/bin/ksh cur_month=`date +%m` cur_year=`date +%Y` prev_month=$(($cur_month-1)) # Check to see if this is January if ... (8 Replies)
Discussion started by: santosham
8 Replies

9. Shell Programming and Scripting

Date increment in the format "YYYYMMDD"

Hi all, I want to increment the date which is in the format "YYYYMMDD". ex: If the date is 20010601 Increment should be: 20010602, 20010603 etc., Any help will be much appreciated. Many Thanks and Regards, Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

10. AIX

Issues with "SU - userid -c command" on system reboot

Hi All! My db2 is started in the AIX /etc/inittab on systemreboot as follows db3:2:once:su - db2inst3 -c db2start >/dev/console 2>1 I changed the .profile of db2inst3 to put an alias to the db2start command as follows alias db2start="/usr/bin/ksh /home/db2inst3/sample/db2start.ksh" When... (1 Reply)
Discussion started by: voorkey
1 Replies
Login or Register to Ask a Question