Cover V08, I03
Listing 1


Questions and Answers

 Q I'm looking for a tool to monitor log files on a UNIX box. I found one a long time ago, written in Perl (if my memory doesn't fail) but can't find it now. It was able to monitor size and do things like gzip logs, rotate them, or send them via SMTP. Can someone point me to such a tool? I have no time to write one. Thanks.

 A The one I am using is an old shell script, which was distributed with smail3 (I think). It can do all of what you asked for, although it certainly can be improved upon. The script is shown in Listing 1 (see page 60).

 Q In a Y2K test server, we are testing three different applications. How can I set the different dates for different sessions of applications at the same time?

 A You cannot do this. The date is kept in the UNIX kernel, using Greenwich time, as the number of seconds since January 1st, 1970. Before the date is displayed by a program, UNIX will take the local time zone into account. This means that you can only have one date set at a time, but that users from anywhere in the world can have the date and time displayed according to where they are located.

 Q How can we change the sequence of Stop+A keys to some other key combination for Solaris 2.5?

 A As far as I now, you cannot do this except by replacing the keyboard and monitor with an old-fashioned terminal, in which case the Shift-Break takes over from Stop-A on the keyboard for a graphical console device.

 Q When I try to delete a large number of files (argument list), UNIX won't let me do it. Is there a way to configure the system to let me delete or move more files?

 A The reason the system will not let you do this is because it has an upper limit on how long an argument list can be. If you are in a directory with a very large number of files and you type rm -rf *, the * will be expanded by the shell to the actual list of files in that directory. When the number of files is very large, it will simply not fit in the space allowed for a command line. However, do not despair! In UNIX, there are always many ways to do a thing, and in this case, the alternative is to use xargs. xargs is a companion program to find. When you run find, there is often no way of knowing how many files it will find that fit the argument list. When you have a very large number of files, you can use xargs to break up the list of files and invoke your program for a subset of the total files. In your case, you can run the following command in the directory in question:

find . -type f -print | xargs rm -rf

Here find will find all files in your directory (and any sub-directories) and print a simple list to standard output. The standard output is picked up by xargs, which will break the list into sizes small enough to fit within a command line. It will then execute the command rm -rf with that list of files. The net result is that all files in that directory tree will be removed, regardless of the number of files.

 Q I currently run NIS(YP) on a DG-UX Aviion machine. When a user forgets his/her password, the only way that I can set a new password, is to delete the user and re-create it. Although this is not a lengthy operation, there must be a way around it. When using yppasswd to change the password, yppasswd asks for the OLD password - if I knew it, I would not need to change it!

 A If you become root on the NIS server itself, you should be able to change the users password without being prompted for the old password. You can, however, only do this on the NIS master, as this operation is not supported from clients for obvious security reasons.

 Q I have a UNIX system with 64 users set up to use the system. But, when more than 32 users try to connect, they get the error: all terminals (tty's) in use. Please help.

 A When a remote user logs into a system, they are using a pseudo-terminal or pty to connect to the system. You need to make sure that there are enough pty's to support all users (or other processes using network access). To do this, you must make sure that there are enough pty'd devices configured (/dev/pty*) and that your kernel is configured to support those devices. Depending on your version of UNIX, you might need to recompile the kernel in order to provide the support for this.

 Q Is there any way of doing a tape to tape archive using tar? I'm using a DLT and a DTF on a Sun and an SG. I basically want to copy the contents of the DLT onto the DTF (this is Sony's Digital Tape Format) but bypass the hard drive stage. I've tried variations of tar xvBf $DLT | tar cvf $DTF - and so on, but to no avail.

 A You cannot use tar to make a tape to tape copy of a tar image unless you first restore the source tape to disk and then create the second tape by making a tar archive of the files you just have restored. Depending on the purpose of the copy, you might be able to do without this level of verification, in which case, you can use the dd command by copying data straight from the DLT to the DFT tape. However, in a worst case scenario, you might be copying bad data from one tape to another without ever knowing it. And if you do not get details, such as the block factors, correct for the two tapes, the result may be completely unreadable afterwards.

About the Author

Bjorn Satdeva is the president of /sys/admin, inc., a consulting firm which specializes in large installation system administration. Bjorn is also co-founder and former president of Bay-LISA, a San Francisco Bay Area user's group for system administrators of large sites. Bjorn can be reached at