The most efficient way to edit more than one file during installation is to define a class and provide a class action script. If you used the build class approach, you would need to deliver one build class script for each crontab file edited. Defining a cron class provides a more general approach. To edit crontab files with this approach, you must:
Define the crontab files that are to be edited in the prototype file.
Create an entry in the prototype file for each crontab file that will be edited. Define the class as cron and the file type as e for each file. Use the actual name of the file to be edited.
Create the crontab files for the package.
These files contain the information you want added to the existing crontab files of the same name.
Create an installation class action script for the cron class.
The sample i.cron script performs the following procedures:
Determines the user ID (UID).
The i.cron script sets the variable user to the base name of the cron class script being processed. That name is the UID. For example, the base name of /var/spool/cron/crontabs/root is root, which is also the UID.
Executes crontab using the UID and the -l option.
Using the -l option tells crontab to send the contents of the crontab file for the defined user to the standard output.
Pipes the output of the crontab command to a sed script that removes any previous entries added with this installation technique.
Puts the edited output into a temporary file.
Adds the data file for the root UID (that was delivered with the package) to the temporary file and adds a tag so you will know where these entries came from.
Executes crontab with the same UID and gives it the temporary file as input.
Create a removal class action script for the cron class.
The r.cron script is the same as the installation script except there is no procedure to add information to the crontab file.
These procedures are performed for every file in the cron class.