Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Aug 2004 13:15:24 -0700
From:      Joshua Tinnin <krinklyfig@spymac.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: crontab question involving cvsup
Message-ID:  <200408261315.24610.krinklyfig@spymac.com>
In-Reply-To: <200408260228.47205.kstewart@owt.com>
References:  <200408260007.26659.krinklyfig@spymac.com> <200408260109.12229.krinklyfig@spymac.com> <200408260228.47205.kstewart@owt.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 26 August 2004 02:28 am, kstewart <kstewart@owt.com> wrote:
> On Thursday 26 August 2004 01:09 am, Joshua Tinnin wrote:
> > On Thursday 26 August 2004 12:42 am, epilogue
> > <epilogue@allstream.net>
> >
> > wrote:
> > > On Thu, 26 Aug 2004 00:07:26 -0700
> > >
> > > Joshua Tinnin <krinklyfig@spymac.com> wrote:
> > > > OK, I have searched the archives, and I can't find that my
> > > > question has been answered previously, but please forgive me if
> > > > that's incorrect.
> > > >
> > > > I'm using (or rather trying to use) cron to update my ports
> > > > tree daily. I've tried several different combinations without
> > > > success, and lately this is what I have in my crontab file:
> > > >
> > > > /usr/local/bin/cvsup -g -L 2
> > > > /home/krinklyfig/supfiles/ports-supfile &&
> > > > /usr/local/bin/portindex && /usr/local/sbin/portsdb -u
> > > >
> > > > It runs as root once a day. What appears to be happening is
> > > > that the cvsup is happening, but portindex is not, and because
> > > > of the latter portsdb -u doesn't either. The reason I know
> > > > cvsup is working is because portindex indicates that the ports
> > > > tree has been updated if I run it manually later, but running
> > > > portversion before manually running portindex will not indicate
> > > > any changes. The cron log doesn't show anything but the
> > > > commands being executed. So, my question is: is this type of
> > > > command valid, or should each command be separate? Or is it not
> > > > working for some other reason?
> > >
> > > man cron gives:
> > >
> > > crontab [-u user] file
> > >
> > > 'file' being the important part, methinks.   ;)
> >
> > I'm not sure what you mean ... If you're wondering, I'm using the
> > main crontab file (/etc/crontab), as right now there's no need for
> > me to use multiple ones.
> >
> > > what you might want to do, is simply write a shell script and
> > > feed that into your crontab.  in case you're not sure how to make
> > > a script, it is very simple and google will return many
> > > tutorials.
> >
> > I had considered this, and eventually would like to do so, as I'd
> > like to add the output of fastest_cvsup to the server listed in the
> > supfile.
> >
> > > in a nutshell, you put the commands you want into a file, make
> > > that file executable (chmod), and away you go.
> > >
> > > the first line of a shell script has an obligatory format and
> > > invokes the shell that will be used.
> > >
> > > #!/bin/sh                  << the leading # is required
> > > /usr/local/bin/cvsup -L 2 /foo/path/to/your/ports-supfile;
> > > # comments are allowed
> > > portindex;
> > > exit
> >
> > Is verbosity of -L 2 allowed in a script without output? IOW,
> > should that first line be:
> >
> > /usr/local/bin/cvsup -L 2 /path/to/supfile > /dev/null 2>&1;
> >
> > Or does it matter if the output has nowhere to go?
> >
> > > note: you might also prefer to end commands with && rather than ;
> > >
> > > i'm new to scripting myself so please forgive my feeble
> > > explanation.
> >
> > I'm pretty new to scripting as well. Does ; allow the next line to
> > run, even if the previous one didn't, as opposed to && which would
> > only allow the next line to run if the previous one was successful?
> > (This would be similar to how a one-line command works outside a
> > script.)
> >
> > > about the commands which you are planning to include, why the
> > > 'portsdb -u'? is that not doing essentially the same work as
> > > 'portindex' ?
> > >
> > > (http://www.freshports.org/sysutils/portindex/)
> >
> > No, portindex doesn't update the database. The command portsdb -U
> > generates an INDEX, which is what portindex does (although
> > portindex does it faster), while portsdb -u generates the INDEX.db
> > from the ports INDEX file. However, the database is generated
> > automatically if need be when it's looked up, so it's not necessary
> > - man portsdb mentions this - but I like to have my ducks in a row,
> > so to speak ;)
> >
> > > anyhow.  hope this helps.
> >
> > Yes, it has me thinking I should probably start testing out a
> > script, but it will include a bit more than just cvsup'ping,
> > updating the INDEX and database. Thanks.
>
> This is my cron job. I don't test for completion because of the
> multiple commands I execute. It doesn't fail very often. It also
> include the usage of portindex and portsdb.
>
> ruby# m uports
> #! /bin/sh
> export
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/us
>r/X11R6/bin:/root/bin cd /root/cvsup
> cvsup -g -L 2 ports-supfile 2>&1 | tee /var/log/build/ports_cvsup.log
>
> cd /var/log/build
>
> # Now convert the log to html`
> cvsuplog < ports_cvsup.log > ports-`date "+%Y%m%d-%H%M"`.html
>
> # Now update the index pages.
> cd /usr/ports
> #
> # make bzip2 backup and save 4 old ones for the days when make index
> # is broken
> #
> rm INDEX.3.bz2
> mv INDEX.2.bz2 INDEX.3.bz2
> mv INDEX.1.bz2 INDEX.2.bz2
> mv INDEX.0.bz2 INDEX.1.bz2
> bzip2 -c INDEX > INDEX.0.bz2
> #
> # get new INDEX
> #make index 2>&1 | tee /var/log/build/make-index-`date
> "+%Y%m%d-%H%M"`.log portindex 2>&1 | tee
> /var/log/build/make-index-`date "+%Y%m%d-%H%M"`.log #
> #fetch www.freebsd.org/ports/INDEX
> #chmod 644 INDEX
> portsdb -u

Excellent. Thanks so much for sending this, as this is just the sort of 
thing I need. I'll work on it a bit tonight to customize it for my 
system. I'm glad you posted this, as in searching the archives I 
noticed you've posted it before, but it's changed since the last time.

- jt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200408261315.24610.krinklyfig>