Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jan 2005 18:24:05 -0600
From:      Kevin Kinsey <kdk@daleco.biz>
To:        Xian <ian@codepad.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: custom periodic scripts
Message-ID:  <41FAD7A5.8010209@daleco.biz>
In-Reply-To: <200501282232.35750.ian@codepad.net>
References:  <200501282232.35750.ian@codepad.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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          *           *           *            
/home/admin/scripts/backup
------------------------------------------------------------------------------------------------------

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41FAD7A5.8010209>