[ale] cron fun

Chuck Huber chuck at cehuber.org
Fri Feb 2 18:45:56 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFw80ziR3HaLbYCa4RAtOwAJ4qAJJL73zWabvDS5PfH2GIqtSVsACgkReg
QBVuev4A8lRDkijSRQSpgoU=
=4sNT
-----END PGP SIGNATURE-----



More information about the Ale mailing list