Store time stamp for .csh shell users

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Store time stamp for .csh shell users
# 1  
Old 01-09-2012
Store time stamp for .csh shell users

How do I store the time stamps of each command executed for C shell users?

However, I am able to set this for Bash users with this command:

Code:
export HISTTIMEFORMAT="%F %T "

This is how a typical .cshrc look like for a Cshell user:

Code:
[root@H99XXX]# more .cshrc

# necessary to get hostname without domain (AIX, OS/390 and NOT sun)
switch (`uname`)
   case AIX*:
   case OS/390*:
   case Linux*:
       alias hostname 'hostname -s'
   breaksw
endsw

set hist=5000------------------i added this
set savehist=5000------------i added this

# SAP environment
if ( -e $HOME/.sapenv_`hostname`.csh ) then 
   source $HOME/.sapenv_`hostname`.csh
else if ( -e $HOME/.sapenv.csh ) then  
   source $HOME/.sapenv.csh
endif

# APO environment                          
if ( -e $HOME/.apoenv_`hostname`.csh ) then
   source $HOME/.apoenv_`hostname`.csh     
endif                                      

# RDBMS environment
if ( -e $HOME/.dbenv_`hostname`.csh ) then 
   source $HOME/.dbenv_`hostname`.csh
else if ( -e $HOME/.dbenv.csh ) then  
   source $HOME/.dbenv.csh
endif

# 2  
Old 01-09-2012
As far as I know, csh does not have that feature but tcsh has it. Check man pages for both.
# 3  
Old 01-09-2012
I do believe you are right, I am not able to find any examples online also except for history query command. Unfortunately the users do not have a tcsh shell.
# 4  
Old 01-18-2012
Solved

I managed to do it in csh with this in place (and the end of .cshrc file)

Code:
echo "Date is: `date`" >> /var/log/user_history/priti_history
set histfile=/var/log/user_history/priti_history
set history=5000
set savehist=5000

Output:

Code:
HAXXX:priti> history
     1  12:21   Date is: Mon Jan 16 12:21:53 JST 2012
     2  12:21   Date is: Mon Jan 16 12:21:54 JST 2012
     3  12:21   echo
     4  19:09   Date i

1. provided that this dir is already created /var/log/user_history/ with enough permissions for users' history logs to get written there:

Code:
[root@H99AXX log]# ls -ld user_history
drwxrwxr-x 2 root root 4096 Jan 16 11:33 user_history
[root@H99A100 log]# pwd
/var/log

[root@H99AXX user_history]# ls -la
total 96
drwxrwxr-x  2 root          root     4096 Jan 16 11:33 .
drwxr-xr-x 17 root          root     4096 Jan 19 04:02 ..
-rw-rw-rw-  1 db2s12        dbs12adm  414 Jan 16 12:01 .db2as_bash_history
-rw-r--r--  1 db2s12        root     2502 Jan 19 03:46 .db2s12_history
-rw-rw-r--  1 ZBGFTPUSR     root      111 Jan 19 10:49 .JP1USERS_bash_history
-rw-r--r--  1 nttd_jp1      root     9056 Jan 18 19:21 .nttd_jp1_bash_history
-rw-r--r--  1 s12adm        root     1787 Jan 19 10:37 .s12adm_history
-rw-r--r--  1 s32adm        root       28 Jan  6 18:38 .s32adm_bash_history
-rw-r--r--  1 sapr3         sapsys   1715 Jan 16 11:49 .sapr3_bash_history
-rw-r--r--  1 SAPServiceS32 root       25 Jan  6 18:37 .SAPServiceS32_bash_history
-rw-r--r--  1 ZODCIFUSR     root      799 Jan  6 20:30 .ZODCIFUSR_bash_history

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script | Parse log file after a given date and time stamp

I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies

2. UNIX for Advanced & Expert Users

Need mtime with time stamp

hi all find /folder1 -mtime 1 >folder1 with the above command , I can get the output of all the files which are modified(within folders and sub folders of folder1) in the last 24 hours. but the listed files output , does not contain the time stamp with it. I request you to give... (4 Replies)
Discussion started by: sidharthmellam
4 Replies

3. Shell Programming and Scripting

Time stamp Difference

I have a log file which wrote time stamp like this 2013-02-11 00:46:40.389037 2013-02-12 11:46:40.197045 can any one help me to get the time stamp difference of these two line in seconds. (4 Replies)
Discussion started by: netdbaind
4 Replies

4. Shell Programming and Scripting

Store Large data in Variable in csh

Hi All, This is my first post!! :) How to store huge data in a single variable in csh. Right now i can store upto ~700kb of data. I still want to store more data and i dont want to use perl. Is there any method to store like that...Please let me know.. Thanks (3 Replies)
Discussion started by: vickra
3 Replies

5. Solaris

System time and Cron time stamp not matching

On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help here is what i get when i check for system date infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies

6. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

7. Shell Programming and Scripting

regarding time stamp

hi everyone i am facing a strange problem here suppose content of my file is a=1,2,3 b=2,3,4 c=4,5,6 time= now the problem is i want to add value in front of time variable and the value should be i format only "HHMMSS" so it should be like this a=1,2,3 b=2,3,4 c=4,5,6... (3 Replies)
Discussion started by: aishsimplesweet
3 Replies

8. Shell Programming and Scripting

How to list Commands used by users & with time stamp

hi, Do anybody know, how to list out all the commands & scripts used by the user & root along with the timestamps under ksh & csh shells. Thanks in advance Regards BS (1 Reply)
Discussion started by: raghunsi
1 Replies

9. Shell Programming and Scripting

Shell Script not showing accurate Time Stamp and Size

Hey guys - I have made this script and for some reason, I dont see time stamp as "Month-Day-YYYY Hours-Mins" - all i see is Month and Day. Also, my file size is approximated. For example, if the size is 19,606KB - the script shows as 20M. Is there a way to see the exact file size? How do i... (2 Replies)
Discussion started by: DallasT
2 Replies

10. Shell Programming and Scripting

greping with time stamp

Hi all, I want to grep a file name with time stamp as 30 minutes how can i??. Ex I will getting outputs in a file every minutes I want to grep it by a time intervals of 30 and show it . Any help will be great ! Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies
Login or Register to Ask a Question