From owner-freebsd-questions@FreeBSD.ORG Sat Jan 29 00:24:13 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B39516A4CE for ; Sat, 29 Jan 2005 00:24:13 +0000 (GMT) Received: from ns1.tiadon.com (SMTP.tiadon.com [69.27.132.161]) by mx1.FreeBSD.org (Postfix) with ESMTP id E2CB943D1F for ; Sat, 29 Jan 2005 00:24:12 +0000 (GMT) (envelope-from kdk@daleco.biz) Received: from [69.27.131.0] ([69.27.131.0]) by ns1.tiadon.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 28 Jan 2005 18:24:10 -0600 Message-ID: <41FAD7A5.8010209@daleco.biz> Date: Fri, 28 Jan 2005 18:24:05 -0600 From: Kevin Kinsey User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041210 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Xian References: <200501282232.35750.ian@codepad.net> In-Reply-To: <200501282232.35750.ian@codepad.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Jan 2005 00:24:11.0290 (UTC) FILETIME=[DABCC7A0:01C50598] cc: freebsd-questions@freebsd.org Subject: Re: custom periodic scripts X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Jan 2005 00:24:13 -0000 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