Sunday, April 12, 2015

Configuring the FreeBSD Periodic Subsystem

As mentioned in the post about the daily periodic script there are some scripts that run daily to clean up various legacy subsystems. Some system administrators may not wish to run these scripts and view them as unnecessary. FreeBSD provides an easy way to modify the behaviour of the periodic subsystem through a simple configuration file.

From the earlier post, it was noted that the system announcements and rwho sub-system are somewhat legacy and probably not used (or even enabled) on modern installations. Particularly on servers that are not intended for end-user login. 

The syntax of the file is very simple and follows the same structure as /etc/rc.conf on FreeBSD. Lines that begin with a pound/hash symbol (#) are treated as comments. Blank lines are ignored. All other lines follow the variable=value syntax. The /etc/periodic.conf file should contain only overrides of the default values found in /etc/defaults/periodic.conf.

periodic.conf

# Local configuration for periodic sub-system.
# This file overrides /etc/defaults/periodic.conf
# for more information: man periodic.conf

# disable archaic system messages cleanup since it is not in-use
daily_clean_msgs_enable="NO"

# disable rwho database cleanup since the rwho daemon isn't running
daily_clean_rwho_enable="NO"

# enable daily cleanup of /tmp
daily_clean_tmps_enable="YES" 

The above example of a customized periodic.conf file makes three changes to the defaults:

  • disables the section in the daily output entitled, "Cleaning out old system announcements:"
  • disables the section in the daily output entitled, "Removing stale files from /var/rwho:"
  • enables a section "Removing old temporary files:"
The first two were mentioned in the earlier post as being legacy and probably not in-use. The server is not intended for end-user login and the administrator does not make use of the system announcements sub-system (part of the mail subsystem) and so there will not be any system announcements to clean. The rwho daemon (rwhod) is not enables so there will not be any entries in /var/rwho. Thus on this particular system, it should be safe to disable these two daily scripts.

The third change is to enable cleanup of /tmp. This is probably not needed on a system without end-user access because only applications, scripts, and the system administrator should ever be using the /tmp filesystem. It is possible that some application or script may not behave properly and could leave files in /tmp when they are no longer needed. The system administrator might similarly forget to clean-up. Thus the periodic script has been enabled to keep things tidy.

The daily tmp cleanup script will, by default, remove any files found in /tmp that are more than 3 days old. This period can be adjusted by setting the daily_clean_tmps_days variable in /etc/periodic.conf

Conclusion

In the default state, FreeBSD's periodic sub-system is pretty well self maintaining and does a reasonable job at trying to keep the system clean as well as providing backups of key system files and providing the system administrator with daily reports. Although adjustments may not be needed in many circumstances, a system administrator will find value in understanding how to make changes to this sub-system when the need arises.



No comments:

Post a Comment