A system slows down and tcsh consumes a lot of memory due to a corrupted .history file

Solution Verified - Updated -


  • Red Hat Enterprise Linux 2.1
  • Red Hat Enterprise Linux 3
  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • RHEL5: tcsh-6.14-14.el5-x86_64
  • RHEL6: tcsh-6.17-8.el6.x86_64


  • The data in the file ".history" becomes malformed and its file size gets larger and larger.
  • Each command history should be recoded in the file with a timestamp line a command entry line which should end with EOL(End Of Line).
  • Example of normal .history file:

    $ cat -n .history  
  • A timestamp and a run command entry are not recorded by turns. Not a run command entry but a timestamp is recorded unexpectedly (see the line 4). Additionally, some entries are merged unexpectedly (see the line 6 and 7 below).

  • Example of malformed .history file :

    $ cat -n .history  
  • A system slows down because csh uses a lot of memory to read such a large .history file.


  • We will not address this issue on Red Hat Enterprise Linux 2.1, 3 and 4.
  • tcsh617-6.17-7.el5 has been released in RHEL5.9 with Advisory RHBA-2013:0052
    • Note: we released errata only for tcsh617 package for RHEL5 system. So if you're using tcsh package based on tcsh-6.14), you need to replace tcsh from tcsh package to tcsh617 package.
  • tcsh-6.17-19.el6_2has been released in RHEL6.2 with Advisory RHBA-2012:0687
  • tcsh-6.18.01-7.el7 has been fixed in RHEL7 GA

Temporary workaround:

Consists of setting the following in ~/.cshrc or on the command line:

set savehist=

The above will prevent any writing to ~/.history file (even the empty file still gets truncated every time) thus there won't be any delay in running scripts and no bug will show up.

Root Cause

  • The main issue which should be fixed is that tcsh does not handle ~/.history file exclusively. The "merge" option causes possibility of a little more unexpected behavior with warning mentioned in man page regarding the "-S" built-in command:
 history \[-hTr\] \[n\]  
 history -S|-L|-M \[filename\] (+)  
 history -c (+)  

 With -S, the second form saves the history list to file-  
 name. If the first word of the savehist shell variable is  
 set to a number, at most that many lines are saved. If the  
 second word of savehist is set to ‘merge’, the history list  
 is merged with the existing history file instead of replac-  
 ing it (if there is one) and sorted by time stamp. (+)  
 \____Merging is intended for an environment like the X Window  
 System with several shells in simultaneous use. Currently  
 it succeeds only when the shells quit nicely one after  
  • Additionally, both a value greater than 0 and "merge" option are set to savehist on csh and this is the default setting in Red Hat Enterprise Linux 5.4 or later:
 $ set | grep savehist  
 savehist (1024 merge)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.


I had a similar problem in my system, the .history file was groing and groing in the oracle home, and hagging our oracle servers