[ale] cron fun
Danny Cox
DCox at icc.net
Fri Feb 2 12:27:05 EST 2007
Robert,
On Fri, 2007-02-02 at 12:03 -0500, Robert L. Harris wrote:
>
> 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
>
>
> ----------------------------------------------------------------------
>
> For some reason it's not properly setting $DATE and instead is trying to
> make OUTFILE="/etc/Packages.dump.week./bin/date +%w.txt" which obviously
> wont' work.
>
> I'm pretty sure I'm not smoking crack, what have I done wrong?
The crontab files aren't shell scripts. The variables being set are
being interpreted by crond, not bash, so command substitution won't
work.
So, you'll probably need to call a wrapper script which will wet
DATE and then OUTFILE, and call /usr/bin/dpkg itself, instead of
directly through cron.
Crack it is! ;-)
--
Daniel S. Cox
Internet Commerce Corporation
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ale
mailing list