[ale] cron fun

Robert L. Harris Robert.L.Harris at rdlg.net
Fri Feb 2 19:09:35 EST 2007



  Well I basically put the whole cron into the script and have a new cron file
which runs the script.  I could have sworn that cron was capable of setting
some variables like this.  Oh well, not the first time I was wrong and I'm
sure it won't be the last.




Thus spake Chuck Huber (chuck at cehuber.org):

> ale-request at ale.org wrote:
> > ----------------------------------------------------------------------
> > 
> > Message: 1
> > Date: Fri, 2 Feb 2007 12:03:00 -0500
> > From: "Robert L. Harris" <Robert.L.Harris at rdlg.net>
> > Subject: [ale] cron fun
> > To: Atlanta Linux Enthusiasts <ale at ale.org>
> > Message-ID: <20070202170300.GZ25038 at rdlg.net>
> > Content-Type: text/plain; charset="us-ascii"
> > 
> > 
> > 
> > Ok, I've got a cronjob, /etc/cron.d/dumppkgs that reads as such:
> > 
> > 
> > 
> > ----------------------------------------------------------------------
> > # /etc/cron.d/php4: crontab fragment for php4
> > #  This purges session files older than X, where X is defined in seconds
> > #  as the largest value of session.gc_maxlifetime from all your php.ini
> > #  files, or 24 minutes if not defined.  See /usr/lib/php4/maxlifetime
> > MAILTO=robert at rdlg.net
> > DATE=`/bin/date +%w`
> > OUTFILE="/etc/Packages.dump.week."$DATE".txt"
> > 
> > # Backup dpkg selections
> > 0 12 * * *     root   /usr/bin/dpkg --get-selections > $OUTFILE
> 
> Danny is right about cron scripts not being shell scripts.
> A wrapper is going to be the best bet.  Try something like:
> 
> savestdout.sh:
> #/bin/bash
> DATE=`/bin/date +%w`
> OUTFILE="/etc/Packages.dump.week."$DATE".txt"
> # redirect stdout to a file
> exec >${OUTFILE}
> # launch the desired program
> exec "$@"
> 
> Then in crontab:
> 0 12 * * * root /full/path/to/savestdout.sh /usr/bin/dpkg --get-selections
> 
> Hope this helps.
> 
> Enjoy,
>     - Chuck
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

:wq!
---------------------------------------------------------------------------
Robert L. Harris                     | GPG Key ID: E344DA3B
                                         @ x-hkp://pgp.mit.edu
DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for              First One Should Be A Man
       no-one else.                       - Manowar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature




More information about the Ale mailing list