Questions and Answers
Jim McKinstry
I need to write a cronjob calling a script that acts similar to Solaris /var/adm/messages. Specifically, I have a file that has messages continuously written to it, but this file can get very large, so every day I want to start with a new file and have the previous days file saved to filename.date. Has anyone tried to do this before?
Check out /usr/lib/newsyslog. In a nutshell, heres how to do it: 1. Add the following to /usr/lib/newsyslog:
LOGDIR=/tmp/logs
LOG=logfile.log
DATE='whatever date command you want'
if test -d $LOGDIR
then
cd $LOGDIR
test -f $LOG && mv $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
fi
2. Add the following to cron (this runs the newsyslog every day at 1:00 a.m.): 0 1 * * * /usr/lib/newsyslog
If your Solaris system does not have the newsyslog script and crontab entry to invoke it, create the newsyslog script manually and add the crontab entry for it.
Whats the difference between hard and soft quotas?
In general,
1. Hard quotas prevent users from writing data to disk. With hard quotas, the utility automatically limits the users disk space for you, and no users are granted exceptions. Once users are about to reach their quota, they come to you for help.
2. Soft quotas send you alerts when users are about to exceed disk space. Unlike hard quotas, there is no physical restriction to prevent users from saving their data. However, you do get alerts and can create a corporate policy to help manage data.
What operating system capabilities are required to allow an OS to be upgraded without taking it offline?
Im not aware of any operating system that can be upgraded without some amount of downtime. Id suggest that if you have this requirement you run in a cluster of two or more servers. Take one server offline, upgrade it, then bring it back into the cluster. Take the next server offline and upgrade it, etc., until all of the servers are upgraded.
I see 2>&1 a lot in crontab files. What does that mean?
There are three standard file descriptors:
1. stdin 0 Standard input to the program.
2. stdout 1 Standard output from the program.
3. stderr 2 Standard error output from the program.
Normally, input is from the keyboard or a file. Output, both stdout and stderr, normally goes to the terminal, but you can redirect one or both of these to one or more files. 2>&1 means take the standard error output from the program and send it to the same place that standard output is going. In addition to file redirection symbols, there are a number of other special symbols you can use on a command line. These include:
; Used to separate two commands on one line.
& Run the command in the background.
&& Run the command following this only if the previous command completes successfully, (i.e., grep string file && cat file).
|| Run the command following only if the previous command did not complete successfully, (i.e., grep string file || echo "String not found").
( ) The command within the parentheses is executed in a subshell.
' ' (forward single quote) Dont allow any special meaning to any characters within these quotations.
\ Take the following character literally. Also used to escape a new-line character so you can continue a command on more than one line.
" " Allow variable and command substitution with theses quotations.
'command' (back quote) Take the output of this command and substitute it as an argument on the command line.
# Everything following until <newline> is a comment.
How do I access my Windows 98 files from my Linux machine?
Assuming that you are talking about two separate systems on the network, try using NFS or Samba. My guess is that what you really have is a dual-booted Linux/Windows system and you want to access your Windows data while booted as Linux. If this is the case, all you need to do is mount the Windows partition and access the data using normal Linux commands.
Typically, the first partition of your first IDE drive is /dev/hda1 (as seen by Linux). If thats your Windows C: drive, then do something like:
mkdir /windows_stuff
mount -t vfat /dev/hda1 /windows_stuff
or, to use what I said in the answer above this one:
mkdir /windows_stuff && \
mount -t vfat /dev/hda1 /windows_stuff
Add an entry to /etc/fstab to make this persistent across boots.
I was looking in my /var/adm/messages file the other day and noticed that it is empty and old. What has happened to my system messages?
Unless youve set up an extensive error logging process, then syslogd (the daemon for routing messages from various services to various log files ) is probably not running. Check if syslogd died:
ps -ef | grep syslogd
If its not running, start it:
/usr/sbin/syslogd
If it is running, check that the file system that contains /var/adm/messages is not full (use df). If it is, clean it up and you should start getting messages again.
Another reason for the system to not have any messages is that it is sending them somewhere else (another host or file). Messages go to another host if /ets/syslog.conf redirects them to loghost and you have a loghost entry in /etc/hosts or in your NIS map. Most systems define themselves as the loghost in /etc/hosts. Check /etc/hosts for the loghost entry. It should be the IP address of your host. On the other hand, if your system is configured to use NIS first, then the loghost file defined in NIS might determine where your messages are going.
To check whether messages are going to another file, look in /etc/syslog.conf. If you dont see a line that sends messages to /var/adm/messages, then that might be the problem. n
About the Author
Jim McKinstry is a Senior Sales Engineer for MTI Technology Corporation (www.mti.com). MTI is a leading international provider of data storage management products and services. He can be reached at: jrmckins@yahoo.com.
|