> > 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. OK, I've moved all of my user crontabs (including root) to /etc/crontab. > 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. Done. > > 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 got it working in /etc/crontab. Should I file a bug for http://www.gentoo.org/doc/en/cron-guide.xml to mention that vixie-cron must be restarted when making changes to /etc/crontab? It says: "Note that only Vixie-cron schedules jobs in /etc/crontab automatically." > 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. Wouldn't you rather use a one-liner like this? iptables -L -n | mail -s "mx1 iptables state" -a "From: root@mx1.example.com" postmaster@example.com - Grant