10.7 mycron, a Small Cron Facility The cron facility in UNIX allows users to execute commands at specified dates and times. This facility is quite flexible and allows regularly scheduled commands. It is implemented with a cron daemon that processes a file containing timing and command information.Implement a simplified personal cron facility called mycron. Write a program that takes one command-line argument. The argument represents a data file containing time intervals and commands. Each line of the data file specifies a command and the frequency at which that command is to be executed. The lines of the data file have the following format. interval command
The interval argument specifies the number of seconds between execution of instances of the command. The command argument is the command to execute with its arguments.
- Implement the preceding cron facility, assuming that none of the intervals in the cron data file are longer than the maximum interval that the timers can handle (about 30 minutes). Call the executable mycron.
- Handle the case in which the intervals can be arbitrarily large. Assume that the number of seconds in the interval will fit in a long. Try to do this without modifying the timer functions.
- Find a way to adjust the starting times so that if two commands have the same interval, they will not always be executing at the same time.
|