Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tail -300 /.sh_history with crontab 2

Status
Not open for further replies.

gatetec

MIS
Mar 22, 2007
420
US
I am running a command, tail -300 /.sh_history, in crontab so that I can get the lines of .sh_history of root acct.

However, tail -300 /.sh_history doesn't return the correct result (just give me 20 some lines) whereas the manual entry on the prompt give me 300 lines correctly.

What would be the cause of this and the right approach with crontab?

thx much

 
The .sh_history file is not a flat ASCII file (includes control chars etc). Try a bit of this for the last 300 lines:

strings /.sh_history | tail -300

You can use the $HISTSIZE environment variable to manage the number of entries retained.

HTH.
 

you can also list last 300 commands using 'fc' command:

eg.

fc -l 300

In AIX 5.3 you can also see the exact date/time of command execution - for that, you need to have EXTENDED_HISTORY=ON and run command:

fc -t -l -300
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top