- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How can i enable time stamp in the history output.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 10:33 AM
тАО09-30-2009 10:33 AM
How can i enable time stamp in the history output.
Is it possible to add time stamp(IE,at what time the particular command was executed) in the history output.
if yes how can i do it,Is there any script for the same...
Thanks & Regards
Jestin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 10:44 AM
тАО09-30-2009 10:44 AM
Re: How can i enable time stamp in the history output.
You can't.
But, you can add this to each .profile file that you want a history on:
vi /home/user/.profile
script > /home/user/history 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 10:48 AM
тАО09-30-2009 10:48 AM
Re: How can i enable time stamp in the history output.
If you want to add the Bash shell to your server (and DO NOT make it the default shell for 'root' as this will render your server inoperable on the next boot), then you can have timestamps in your history.
Set the Bash HISTTIMEFORMAT environmental variable. See the Bash documentation.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 10:53 AM
тАО09-30-2009 10:53 AM
Re: How can i enable time stamp in the history output.
I should be more clear. In Bash, in '.bash_profile' you can do:
# HISTTIMEFORMAT='%m%d-%H%M%S: '
...or whatever you want the timestamp format to be. The formatting directives are like those you would use for 'date' (in reality they are from 'strftime()').
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2009 12:49 PM
тАО09-30-2009 12:49 PM
Re: How can i enable time stamp in the history output.
for example I use it in linux RedHat :
# export HISTTIMEFORMAT=├в %F %T ├в
# history | more
1 2008-08-05 19:02:39 service network restart 2 2008-08-05 19:02:39 exit 3 2008-08-05 19:02:39 id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 03:37 AM
тАО10-05-2009 03:37 AM
Re: How can i enable time stamp in the history output.
If I did not get mistakenly your concept , it does not work in Posix , just got stuck due to script activation..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2009 07:56 AM
тАО10-05-2009 07:56 AM
Re: How can i enable time stamp in the history output.
Try adding the following lines to your .profile and re-accessing it :
#trap to timestamp commands
trap 'date "+# %c" | read -s' debug
Then you should see something similar to the following in your history file :
# Mon Oct 5 16:50:13 2009
ls -ail
# Mon Oct 5 16:50:18 2009
bdf
# Mon Oct 5 16:50:21 2009
tail /.sh_history_markme
# Mon Oct 5 16:50:32 2009
vi .profile
Regards,
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 12:08 PM
тАО10-06-2009 12:08 PM
Re: How can i enable time stamp in the history output.
#!/usr/bin/sh
set -u
for ACTIVE in $(who -q | grep -v users)
do
echo "## $(date)" >> ~$ACTIVE/.sh_history
done
This script uses who -q to get just a list of logged-in users, then appends the current date-time to .sh_history in their home directory. You can save this as a script and put it into root's cron to run a few times during the day.
Now everyone's .sh_history will be time stamped while they are logged in.
Bill Hassell, sysadmin