Notes for Week 9

  1. fcron is used to schedule jobs to be done on a periodic basis. In order to use fcron:

  2. Useful fcrontab entries are

  3. The characters "@", "&" or "%frequency" can be followed by comma-separated options:

    See the section 5 fcrontab man page for more options.

  4. Some potentially useful fcron "one-liners":

  5. Usually it is better to use a shell script for "command". For instance, the following script is an improvement on the last example:
    for f in $* ; do
       mv /var/log/$f.log /var/log/$f.log.$(date -d yesterday +%y%m)
       touch /var/log/$f.log
    /etc/rc.d/init.d/sysklogd restart
    Now the command
    logrotate auth boot daemon kern mail sys user
    will rotate all of the system logs. Note the "for" command is similar to the FOR command in Windows.
  6. EXERCISES for Week 9:

    1. Set up an fcron job to run your backup script each day at 9:00 PM.
    2. Set up an fcron job to rotate one or more log files every two weeks between 1:00 and 2:00 AM Monday morning. Note that you will have to add the day to the file name (change +%y%m to +%y%m%d).

©2014, Kenneth R. Koehler. All Rights Reserved. This document may be freely reproduced provided that this copyright notice is included.

Please send comments or suggestions to the author.