Re: run cron every four weeks?

From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 08/11/03


Date: 11 Aug 2003 21:47:53 GMT

On Mon, 11 Aug 2003 at 21:33 GMT, Joan Valduvieco wrote:
> Hi
> I would prefer an slightly modified version.
> Here it goes:
>
> #!/bin/bash
>
> . counterfile
>
> counter=$(( $counter + 1 ))
>
> if [ $counter == 4 ]
> then
> counter=0
> do all the rest of the stuff
> fi
> echo "counter=$counter" > counterfile

     You can save another line with:

. counterfile
counter=$(( $counter + 1 % 4 ))

if [ $counter -eq 0 ] ## more portable than ==
then
         do all the rest of the stuff
fi
echo "counter=$counter" > counterfile

-- 
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: run cron every four weeks?
    ... On Mon, 11 Aug 2003 at 21:33 GMT, Joan Valduvieco wrote: ... My code in this post is copyright 2003, Chris F.A. Johnson ... and may be copied under the terms of the GNU General Public License ...
    (comp.sys.hp.hpux)
  • Re: run cron every four weeks?
    ... On Mon, 11 Aug 2003 at 21:33 GMT, Joan Valduvieco wrote: ... My code in this post is copyright 2003, Chris F.A. Johnson ... and may be copied under the terms of the GNU General Public License ...
    (comp.sys.sun.admin)
  • Re: run cron every four weeks?
    ... echo "counter=$counter"> counterfile ... Good luck. ... Chris F.A. Johnson wrote: ...
    (comp.unix.questions)
  • Re: run cron every four weeks?
    ... "Chris F.A. Johnson" wrote: ... However, none of that is as good as using the date command, ...
    (comp.sys.sun.admin)
  • Re: run cron every four weeks?
    ... "Chris F.A. Johnson" wrote: ... However, none of that is as good as using the date command, ...
    (comp.sys.hp.hpux)