Register
It is currently Mon Dec 22, 2014 4:56 am

Strange output from history command


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Jan 19, 2012 12:55 am   

Joined: Fri May 07, 2010 4:04 am
Posts: 7
Hello,

I have a bash script that puts the output of the history command and the crontab into a file and a perl script thats sends it via email.

The bash script is the following:

Code:
#!/bin/bash

FILE=history_crontab
HISTFILE=~/.bash_history
cat /dev/null > $FILE

set -o history

echo "Command history and crontab for User:  `whoami`" >> $FILE
echo >> $FILE
echo >> $FILE

echo "History: " >> $FILE
echo >> $FILE

history >> $FILE
echo >> $FILE

echo "Crontab: "  >> $FILE
echo >> $FILE

history -c
echo "" > $HISTFILE

crontab -l >> $FILE


Though, some times I get hashes followed by numbers...

Code:
1  #1326782483
     2  cd bin/pots_instances/new
     3  #1326782491
     4  less all_cards_columns
     5  #1326782503
     6  ./make_columns.sh times_0112
     7  #1326785639
     8  ./make_columns.sh times_0113
     9  #1326785891
    10  ./make_columns.sh times_0114
    11  #1326786180
    12  ./make_columns.sh times_0115
    13  #1326786502
    14  ./make_columns.sh times_0116
    15  #1326797365
    16  less kifisia.sh
    17  #1326797372
    18  less make_columns.sh
    19  #1326797385
    20  vi make_columns.sh
    21  #1326797409
    22  less alarms_with_extracted_tams
    23  #1326797425
    24  less thess
    25  #1326797437
    26  less grep_alarms.sh
    27  #1326797444
    28  less grep_customers.sh
    29  #1326797457
    30  cls
    31  #1326806953
    32  cd
    33  #1326806954
    34  cd test
    35  #1326806958
    36  ls logs
    37  #1326806972
    38  cd cdb-meminfo
    39  #1326806977
    40  cd files/
    41  #1326806982
    42  less Galatsi_2.txt
    43  #1326806993
    44  cd ..
    45  #1326806994
    46  ls
    47  #1326807015
    48  tar jxvf cdb-meminfo.tar.bz2
    49  #1326807048
    50  unzip cdb-meminfo.zip
    51  #1326807051
    52  less cdb-meminfo/files/Keratsini_1.txt
    53  #1326807058
    54  rm -r cdb-meminfo
    55  #1326808762
    56  exit


Does anybody know why?

Thanks,

George.


Top
 Profile  
 PostPosted: Thu Jan 19, 2012 10:39 am   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
If I had to guess, those #s are date/time stamps for history.
Code:
date -d @1326808762
= Tue Jan 17 08:59:22 EST 2012

If you want history plain, I use
Code:
unset HISTTIMEFORMAT
alias hist='history | sed '\''s/^[ 0-9]* //'\'''
hist


Code:
1326782503
1326785639
1326785891
1326786180
1326786502
1326797365
1326797372
1326797385
1326797409
1326797425
1326797437
1326797444
1326797457
1326806953
1326806954
1326806958
1326806972
1326806977
1326806982
1326806993
1326806994
1326807015
1326807048
1326807051
1326807058
1326808762


using that technique comes out to
Code:
Tue Jan 17 01:41:43 EST 2012
Tue Jan 17 02:33:59 EST 2012
Tue Jan 17 02:38:11 EST 2012
Tue Jan 17 02:43:00 EST 2012
Tue Jan 17 02:48:22 EST 2012
Tue Jan 17 05:49:25 EST 2012
Tue Jan 17 05:49:32 EST 2012
Tue Jan 17 05:49:45 EST 2012
Tue Jan 17 05:50:09 EST 2012
Tue Jan 17 05:50:25 EST 2012
Tue Jan 17 05:50:37 EST 2012
Tue Jan 17 05:50:44 EST 2012
Tue Jan 17 05:50:57 EST 2012
Tue Jan 17 08:29:13 EST 2012
Tue Jan 17 08:29:14 EST 2012
Tue Jan 17 08:29:18 EST 2012
Tue Jan 17 08:29:32 EST 2012
Tue Jan 17 08:29:37 EST 2012
Tue Jan 17 08:29:42 EST 2012
Tue Jan 17 08:29:53 EST 2012
Tue Jan 17 08:29:54 EST 2012
Tue Jan 17 08:30:15 EST 2012
Tue Jan 17 08:30:48 EST 2012
Tue Jan 17 08:30:51 EST 2012
Tue Jan 17 08:30:58 EST 2012
Tue Jan 17 08:59:22 EST 2012


HTH.


Top
 Profile WWW  
 PostPosted: Fri Jan 20, 2012 12:42 am   

Joined: Fri May 07, 2010 4:04 am
Posts: 7
thanks alot!


Top
 Profile  
 PostPosted: Fri Jan 20, 2012 5:58 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
You're very welcome.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP