custom periodic scripts

Kevin Kinsey kdk at
Fri Jan 28 16:24:13 PST 2005

Xian wrote:

>How would I go about adding scripts to periodic? I particular I have a couple 
>of scripts to fetch virus definitions and scan my system.
>I gathered the is a 'proper' way to do it by using /usr/local/etc/periodic but 
>not how to do it.

Well, you could write shell scripts and put them in the proper dirs
under /usr/local/etc/periodic, but probably the Right Thing (TM)
to use is cron(8).  It's there for this purpose.

#sudo crontab -l
#min    hour    day     mon     weekday         command

# Maintenance - antivirus scanner

30      */4        *           *          *            
/usr/local/bin/freshclam > /dev/null 2>&1

# Backup Script

30      3          *           *           *            

Just run "crontab -e" as the user who needs to run the
jobs; your EDITOR will open, and the example above should
clue you in on some things. 

Note that cron(8) needs full paths as it doesn't inherit
an environment from you, and also that he uses /bin/sh,
so commands aren't entered in tcsh fashion....

In this example, freshclam is run at half past the hour, every
four hours; the backup script runs at 0330 daily.  Since this
is root's crontab, any output from the backup script is
mailed to root; in the freshclam example, all output, whether
error or standard output, is deleted....

Kevin Kinsey

More information about the freebsd-questions mailing list