---------------------------------------------------------------------------- The Florida SunFlash Tips: catman, cron and subject SunFLASH Vol 23 #23 November 1990 ---------------------------------------------------------------------------- I have received a number of technical articles from Tony Brooks, a Sun engineer. Some articles were written by Tony and others he has collected from other engineers. I will be posting these articles to SunFlash over the next few weeks. I hope that you enjoy them and find them useful. If you have any comments on them, please send them to me and I'll give them to Tony. -johnj -------------------------------------------------------------------------------- catman --- pre-formatting the online manual pages cron --- scheduling jobs to be run on a regular basis subject --- setting the subject line in mail messages -------------------------------------------------------------------------------- Subject: catman If you have the on-line man pages installed on your machine and it takes a few seconds to view a man because i.e.: % man ioctl Reformatting page. Wait... done IOCTL(2) SYSTEM CALLS IOCTL(2) NAME ioctl - control device SYNOPSIS int ioctl(des, request, arg) int des, request; etc. To speed up the viewing of the on-line man pages just do the following as "root": # /usr/etc/catman -M /usr/man & Note: This will take some time and it will consume more disk space. This will also create an index file for use with the -k (keyword) option to man. You can find all of the manual pages that include a keyword with the command: man -k keyword In fact, the output of "man -k keyword" is man (1) - display reference manual pages; find reference pages by keyword whatis (1) - display a one-line summary about a keyword The man command will fetch a formatted manual page from the 'cat' directories. (/usr/man/cat1 for the man pages in /usr/man/man1, etc.) If there is no formatted manual page in the `cat' directory, but the directory exists, then man will format the manual page and save it in the` cat directory. The next time that that manual page is request, man does not have to format it. -------------------------------------------------------------------------------- Subject: cron You can submit jobs and have them run at specific times with cron(8), which is the system clock daemon. For example, what if I wanted to echo something to /dev/console every minute. All that I need to do is: [[[ DO NOT USE A PUBLICLY WRITEABLE DIRECTORY TO STORE YOUR CRON INITIATED COMMAND FILES - johnj ]]] 1) create a file with the following format: % vi /home/johnj/filename * * * * * /home/johnj/my_script 2) create the script (job) to be run at the specific times: % vi my_script #!/bin/sh echo "Started from crontab" 3) make the script executable % chmod 777 /home/johnj/my_script 4) tell cron about jobs to be scheduled % crontab /home/johnj/filename After you have created your cron entry, you may want to use crontab -e to edit it further. The above will register the above script with the system clock i.e. cron(8). This cron job will run every minute, forever (see below). Each line in a crontab file consists of six fields, separated by spaces or tabs, as follows: * * * * * /home/johnj/my_script | | | | | | minutes hours day-of-month month day-of- week command minutes Minutes field, which can have values in the range 0 through 59. hours Hours field, which can have values in the range 0 through 23. day-of-month Day of the month, in the range 1 through 31. month Month of the year, in the range 1 through 12. day-of-week Day of the week, in the range 0 through 6. Sunday is day 0 in this scheme of things. For backward compatibility with older sys- tems, Sunday may also be specified as day 7. command Command to be run. A percent character in this field (unless escaped by \) is translated to a NEWLINE character. Only the first line (up to a % or end of line) of the command field is executed by the Shell. The other lines are made available to the command as standard input. Any of fields 1 through 5 can be a list of values separated by commas. A value can either be a number, or a pair of numbers separated by a hyphen, indicating that the job is to be done for all the times in the specified range. If a field is an asterisk character (*) it means that the job is done for all possible values of the field. CRONTAB(1) USER COMMANDS CRONTAB(1) NAME crontab - install, edit, remove or list a user's crontab file SYNOPSIS crontab [ filename ] crontab -e [ username ] crontab -l [ username ] crontab -r [ username ] OPTIONS -e Make a copy of the current user's crontab file, or create an empty file if it does not exist, and edit that file. The vi(1) editor will be used unless the environment variable VISUAL or EDITOR indicates an alternate editor. When editing is complete, install the file as the user's crontab file if it was modified. If a username is given, the specified user's crontab file is edited, rather than the current user's crontab file; this may only be done by the super-user. -l List the user's crontab file. -r Remove the current user's crontab file from the crontab directory. If a username is given, the specified user's crontab file is removed, rather than the current user's crontab file; this may only be done by the super-user. (For one time execution of a job, see the at(1) command.) ---------------------------------------------------------------------------- Subject: Subject lines in mail Question: Is there an easy way to add a "Subject:" line for mail without actually going into mail each time? Most of the time I use mailtool but other times I am creating a piece of mail in one of my windows and I'd like to save a couple of steps by not going into mail to insert the "Subject:" line setting before sending the mail. Answer: There are several useful options that /usr/ucb/mail provides I'll just mention the one that applies to the above scenario. If you need more information take a look at the man page for mail(1). ****************************************************************** MAIL(1) USER COMMANDS MAIL(1) -s subject Set the Subject header field to subject. ~s subject Set the subject line to subject. ****************************************************************** You can use "~s" (Tilde Escape) to insert a "Subject:" field line while inside a message that you want to send: % vi /tmp/letter ~s Letter Heading Have a nice weekend. % mail air@jordon < /tmp/letter You can use the "-s" OPTION to insert a "Subject:" field line from the command line: % vi /tmp/letter Have a nice weekend. % mail -s "Letter Heading" air@jordon < /tmp/letter In both of the examples above when air@jordan receives the mail the "Subject:" field line will be "Letter heading". (note that you have to be careful when sending mail that describes the tilde commands. If you have the ~ at the start of the line, it will be processed as a command to mail and not the contents of the mail message ! Note that an extra space precedes the above examples.) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Sunflash is an electronic mail news service from Sun Microsystems, Ft. Lauderdale, Florida, USA. It is targeted at Sun Users and Customers. For additional information about SunFlash send mail to info-sunflash@sunvice.East.Sun.COM SunFlash is distributed via a hierarchy of aliases. Try to address change requests to the owner of the alias that you belong to. If you want to be added to the SunFlash alias, please contact the systems engineers at your local Sun office and/or send mail to sunflash-request@sunvice.East.Sun.COM. All prices, availability, and other statements relating to Sun or third party products are valid in the U.S. only. Please contact your local Sales Representative for details of pricing and product availability in your region. Descriptions of, or references to products or publications within SunFlash does not imply an endorsement of that product or publication by Sun Microsystems. Address comments to the SunFlash editor (John McLaughlin) at sun!sunvice!flash or flash@sunvice.East.Sun.COM. (305) 776-7770.