Article Listing 1 Listing 2 Listing 3 Listing 4
Sidebar jun2004.tar

Auxiliary Scripts

datediff

datediff (Listing 2) determines the number of seconds between two date-time strings. To perform the date arithmetic between the date-time objects, we use Scaliger's Julian Date algorithm. For a complete description and implementation of this algorithm, please see the "Date Arithmetic with the Shell" article from the July 2003, Sys Admin (http://www.samag.com/documents/s=8284/sam0307b/0307b.htm).

Scaliger's algorithm is only in scope between years 1801 to 2099. For dates that fall within this range, check_cron uses this algorithm. Outside the 1801 to 2099 date range, datediff uses a brute-force method to determine the number of seconds between two date-times.

secs2dhms

secs2dhms (Listing 3) converts a number of seconds to an equivalent number of days, hours, minutes, and seconds with corresponding labels. For example:

secs2dhms 94550
returns the following:

1 day 2 hours 15 minutes 50 seconds
Setting the Environment

The script /etc/setenv_path, listing 4, is tailored to our environment. It can be sourced by other shell scripts to assert the PATH, MANPATH, and FPATH variables.