delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/17/13:52:25

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <BAY102-DAV9AC7A81D5C3AD1BC2DABFA9280@phx.gbl>
X-Originating-Email: [unknown_kev_cat AT hotmail DOT com]
X-Sender: unknown_kev_cat AT hotmail DOT com
From: "Tacvek" <unknown_kev_cat AT hotmail DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Re:Cron.Hourly
Date: Sun, 17 Apr 2005 13:52:06 -0400
MIME-Version: 1.0
X-OriginalArrivalTime: 17 Apr 2005 17:52:07.0461 (UTC) FILETIME=[2C139550:01C54376]

> How do I get the folders /etc/cron.hourly, etc/cron.daily etc/cron.weekly
> correctly working in cygwin?
> regards
> -totte

Using etc/cron.* was an old way of doing things. Debian has long since
dropped support for this. The only distro I know that still supports this is
redhat.

Nevertheless, I know it can be very useful and I feel nice today so I will
tell you what you need to do.

(Caveat: I have not tested these, but they should work. I'm not certain of
the copyright but they clain to be from an old debian cron (despite saying
slackware) so the licence should be free.)

Add the folowing to the bootom of crontab (I think it is located at
etc/crontab):

------------------CUT HERE------------------
# Run scripts in cron.hourly on first minute of every hour
01 * * * * run-parts /etc/cron.hourly
# Run scripts in cron.daily at 0:02 each day
02 0 * * * run-parts /etc/cron.daily
#Run scripts in cron.weekly at 2:45 each Saturday
45 2 * * 6 run-parts /etc/cron.weekly
#Run scripts in cron.monthly at  0:03 on the firstday of each month
03 0 1 * * run-parts /etc/cron.monthly
#Run scripts in cron.yearly at 0:04 each January 1.
04 0 1 1 * run-parts /etc/cron.yearly
----------------END CUT HERE----------------


Then create /bin/run-parts using the text below. After you have created it
run 'chmod 755 /bin/run-parts'.

------------------CUT HERE------------------#!/bin/bash
# run-parts:  Runs all the scripts found in a directory.

# keep going when something fails
set +e

if [ $# -lt 1 ]; then
  echo "Usage: run-parts <directory>"
  exit 1
fi

if [ ! -d $1 ]; then
  echo "Not a directory: $1"
  echo "Usage: run-parts <directory>"
  exit 1
fi

# There are several types of files that we would like to
# ignore automatically, as they are likely to be backups
# of other scripts:
IGNORE_SUFFIXES="~ ^ , .bak .new .rpmsave .rpmorig .rpmnew .swp"

# Main loop:
for SCRIPT in $1/* ; do
  # If this is not a regular file, skip it:
  if [ ! -f $SCRIPT ]; then
    continue
  fi
  # Determine if this file should be skipped by suffix:
  SKIP=false
  for SUFFIX in $IGNORE_SUFFIXES ; do
    if [ ! "`basename $SCRIPT $SUFFIX`" = "`basename $SCRIPT`" ]; then
      SKIP=true
      break
    fi
  done
  if [ "$SKIP" = "true" ]; then
    continue
  fi
  # If we've made it this far, then run the script if it's executable:
  if [ -x $SCRIPT ]; then
    echo "$SCRIPT:"
    echo
    $SCRIPT 2>&1
    echo
  fi
done

exit 0
----------------END CUT HERE----------------

Finally here is a man page that you can place as run-parts.1 in
/usr/share/man/1/

------------------CUT HERE------------------
\" -*- nroff -*-
ds g \" empty
ds G \" empty
\" Like TP, but if specified indent is more than half
\" the current line-length - indent, use the default indent.
de Tp
ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
el .TP "\\$1"
.
TH RUN-PARTS 8 "14 Apr 2002" "Slackware Version 8.1.0
SH NAME
run-parts \- run scripts found in a directory
SH SYNOPSIS
B run-parts <directory>
LP
SH DESCRIPTION
B run-parts
is a utility that will run scripts that are found in a directory.  For
example,
it might be useful to create an /etc/cron.daily directory and put scripts in
there for daily cron jobs.  Then
B run-parts
can be called once a day from root's crontab to run all the scripts found in
/etc/cron.daily:

40 4 * * * run-parts /etc/cron.daily

B run-parts
automatically skips files with certain suffixes that are generally
associated
with backup or extra files.  Any file that ends in one of these will be
silently
ignored:  ~ ^ , .bak .new .rpmsave .rpmorig .rpmnew .swp
SH AUTHOR
Patrick J. Volkerding <volkerdi AT slackware DOT com>, with ideas borrowed from the
Red Hat and Debian versions of this utility.
SH "SEE ALSO"
BR crond(8),
BR crontab(8).
----------------END CUT HERE----------------


If that is all then goodbye.
Tacvek 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019