home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 24.1 Instead of Removing a File, Empty It Chapter 24
Other Ways to Get Disk Space
Next: 24.3 Unlinking Open Files Isn't a Good Idea
 

24.2 Save Space with Bit Bucket Log Files and Mailboxes

Some UNIX programs - usually background or daemon programs - insist on writing a log file. You might not want the log file itself as much as you want the disk space that the log file takes. Here are a few tips:

  • Some programs will write to a log file only if the log file exists. If the program isn't running, try removing the log file.

  • If you remove a log file and the program recreates it, look for command-line options or a configuration file setup that tells the program not to make the log file.

  • If your system has symbolic links (18.4 ) , try replacing the log file with a symbolic link to /dev/null (13.14 ) :

    # rm logfile
    
    
    # ln -s /dev/null logfile
    
    

    If you're lucky, the program won't complain and will throw all its messages in the bit bucket. Watch out for programs that run at reboot or from the system crontab (40.12 ) to truncate and replace the log file. These programs might replace the symbolic link with a small regular file that will start growing again.

  • Does a system mailbox for a user like uucp keep getting mail (1.33 ) that you want to throw away? You may be able to add a .forward file to the account's home directory with this single line:

    /dev/null

    Or add an alias in the system mail alias file that does the same thing:

    uucp: /dev/null

    If your system has a command like newaliases to rebuild the alias database, don't forget to use it after you make the change.

- JP


Previous: 24.1 Instead of Removing a File, Empty It UNIX Power Tools Next: 24.3 Unlinking Open Files Isn't a Good Idea
24.1 Instead of Removing a File, Empty It Book Index 24.3 Unlinking Open Files Isn't a Good Idea

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System