From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 197141381F3 for ; Thu, 13 Dec 2012 01:03:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7AA3CE0417; Thu, 13 Dec 2012 01:03:05 +0000 (UTC) Received: from mail2.viabit.com (mail2.viabit.com [65.246.80.16]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B16A121C04D for ; Thu, 13 Dec 2012 01:01:32 +0000 (UTC) Received: from [172.17.29.6] (vpn1.metro-data.com [65.213.236.242]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail2.viabit.com (Postfix) with ESMTPSA id 3YMGmq6zgWz1hfM for ; Wed, 12 Dec 2012 20:01:31 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=orlitzky.com; s=mail2; t=1355360492; bh=DfO1lxJnbcgqhwkFBe3NT783FUrVlHTp2nRs/WtkaKE=; h=Date:From:To:Subject:References:In-Reply-To; b=W8nO9ak2LxVc7ZzdO3DG2hYAlc+hrbgqT6dapbgoimTPZHBglggPm4GY+AuIClRWP XKM100S2rQ1gs8VMxBcS62K9UTvLEVq/N9lXlgEq3XnWp1Tt+EyelNaHLBuyO8Q+Ri qMAgsOZ14RWrvGs3BiCDXEI/p5INcgcbkfqlIpwc= Message-ID: <50C928EA.7000706@orlitzky.com> Date: Wed, 12 Dec 2012 20:01:30 -0500 From: Michael Orlitzky User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121104 Thunderbird/10.0.10 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] crontab questions References: <50C7F69B.6080100@orlitzky.com> In-Reply-To: X-Enigmail-Version: 1.3.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Archives-Salt: 2987051b-d235-4fb4-8b9f-59c6ae559547 X-Archives-Hash: 33abb9139770d9f61ff68f9d40646e56 On 12/12/2012 05:09 PM, Grant wrote: >> >> at roughly the time specified in /etc/crontab. If any of those >> directories contain scripts, they're run in "alphabetical" order, i.e. >> how `ls` would sort them. > > Thanks Michael. I'd like to have more control over when the commands > are run. Maybe the system crontab (cronbase) should be used when that > control isn't necessary or to allow programs to add stuff to a crontab, > and a user crontab should be used when more control is necessary? > I personally like the idea of the cron.{daily,weekly,...}, but the implementation is a little goofy. On our mail server, I've added an additional directory called cron.bihourly to update virus/spam signatures every two hours. The simplest way to accomplish this is to add, # Run every two hours 0 */2 * * * root find -L /etc/cron.bihourly -type f -executable \ -execdir '{}' \; in the global /etc/crontab. I'm sure this is horribly deficient according to whoever implemented the run-crons stuff, but for me the additional clarity is worth it. You can of course add anything else you like in the global/user crontabs, and they'll work normally. But be careful: do you really want `emerge -puDN` to run 15 minutes after you start an `eix-sync`? Or do you just want it to run when `eix-sync` is done? If it's the latter, you don't want to schedule it 15 minutes later -- you could hit a slow mirror and still be updating when the `emerge` kicks off. In that case it's better to put all of the commands in one script, and schedule that when you want. That way the commands occur in sequence, and you can bail out if something fails. >> To fix the Subject/From headers, try, >> >> http://www.postfix.org/header_checks.5.html >> >> I've never had to use them myself, but I think the REPLACE action will >> do what you want. The alternative is to replace the sendmail binary with >> something that executes e.g., >> >> sed -e 's/Subject: Cron <[^>]> /Subject: /g' | /the/actual/sendmail >> >> Both feel a little dirty, but the header checks are less likely to break >> something assuming that they will work on a client-provided From header. > > I think it's better for me to pipe the commands to mailx. I get mail if > I run this on the command line > > emerge -pvDuN world | /usr/bin/mail -s "subject" -a "From: from" > my@email.com > > But I don't get any mail when it runs in the crontab. Do you know why > that's happening? I do get mail from 'emerge -pvDuN world' run in the > crontab without piping it to mail. I'm not sure. I do the same thing, though, albeit with a temporary file (and it works). Maybe try `echo`ing the output to a file? This script emails me the current iptables to make sure fail2ban hasn't gone berserk: #!/bin/bash # Send the current iptables -L -n output to the postmaster. TMPFILE=/tmp/iptables-state.log MAILADDR="postmaster@example.com" echo "To: $MAILADDR" > $TMPFILE echo "From: root@mx1.example.com" >> $TMPFILE echo "Subject: mx1 iptables state" >> $TMPFILE iptables -L -n >> $TMPFILE sendmail -f root@mx1.example.com \ $MAILADDR \ < $TMPFILE rm $TMPFILE It's not very fancy but it does work. If a temp file works for you, it might help you narrow down the problem.