delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 59329397EC3A |
DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
s=default; t=1623238168; | |
bh=rhYpyvwtqpFd6DFxzMap4EuHBWWtRbPdSZBxe27vEe4=; | |
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: | |
List-Help:List-Subscribe:From:Reply-To:From; | |
b=QvQ5IsGsN1FaIljAQtkhWnMgOnI/nQVnGGu3dmMZnz57WZt2ZCflXpnYt0PirVBJ8 | |
jqFv8xCIVIegVbQy0JT3DRTlCl0/dIja5tmz1owmpQiQTOQHffav4aOpfs8gXurATe | |
+WIGIY2SjMFpZg1Cz1rNeoH24YoqAtYQyWDzWSyk= | |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DMARC-Filter: | OpenDMARC Filter v1.4.1 sourceware.org DC2713891C17 |
X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; |
d=1e100.net; s=20161025; | |
h=x-gm-message-state:mime-version:from:date:message-id:subject:to; | |
bh=sKxTKyrxsubwoNU1mufD7uAW9wnQYBGhFSVNOTwtt/w=; | |
b=Sudg/jbHuXfjtqgK/NwkGYrbK0nXy58k4G20U+e5BUjjCoqsnta4XgBumnJBtO0aZA | |
3TyEYP576L4agLqvUSCeUeR49GhD2IuGTY12gFE1ar4OmhB3whR4QJ6oOAQh3QBsik1+ | |
54j8EpiCIYl0RrQwoLH1eqok/Sht+tF3FxVxRLxMaNOOYbohJ3nOGTy5TGayvhEYar0l | |
HWASvj/9Si0TLk+UvLdAbx9/mZI0GgSeGkuXWKOeQS52FyVeLIPkPUYWolOD9tYNU+Nt | |
JOc3DFbKNRV5LMexfJ1Fm5r942M0JDx1hYox2eSjjCa2Nd5lvIjd2X78F53rpvA2CRYZ | |
ytaA== | |
X-Gm-Message-State: | AOAM531v1FKRpXO/UTv0lEELgGWbJWKATp2WZD3uRxkGD61DTvYYwfJI |
vYmqtTs1mX74t7FWjmo3f1DemY+HUdlLn90O6tWn9qQAUavmXA== | |
X-Google-Smtp-Source: | ABdhPJxjxy+b1Oosr/XNLArXjXTrsGbqt+ILbFQkb4mZN3M5PtXBFGa7CVFRPKUNS574oUs+G+U4c+On3qgTwGt5D1o= |
X-Received: | by 2002:a37:664b:: with SMTP id a72mr21486835qkc.389.1623238095063; |
Wed, 09 Jun 2021 04:28:15 -0700 (PDT) | |
MIME-Version: | 1.0 |
Date: | Wed, 9 Jun 2021 04:28:05 -0700 |
Message-ID: | <CA+PLHcG84pBMtotgKRnmk0jSKsT4icfWfkj6Qz=3i4dCm_J8EA@mail.gmail.com> |
Subject: | Using /etc/cron.{daily, weekly, |
monthly} on Cygwin (/usr/bin/run-parts) | |
To: | cygwin AT cygwin DOT com |
X-Spam-Status: | No, score=-1.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, |
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, | |
RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, | |
TXREP autolearn=ham autolearn_force=no version=3.4.2 | |
X-Spam-Checker-Version: | SpamAssassin 3.4.2 (2018-09-13) on |
server2.sourceware.org | |
X-Content-Filtered-By: | Mailman/MimeDel 2.1.29 |
X-BeenThere: | cygwin AT cygwin DOT com |
X-Mailman-Version: | 2.1.29 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
From: | Joe Smith via Cygwin <cygwin AT cygwin DOT com> |
Reply-To: | Joe Smith <joeinwap AT gmail DOT com> |
Sender: | "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com> |
Please add 'run-parts' to Cygwin. I have been using the attached program (copied from Debian) successfully with Vista, Windows-7, and Windows-10. mintty screen dump #!/bin/bash # Name: /usr/bin/run-parts Modified by Joe Smith (joeinwap,gmail) # Purpose: Runs jobs sequentially at regular intervals (daily,weekly,monthly) # Concept taken from Debian, copied from RHEL-5, modified for Cygwin. # See end for "How to run cron jobs with elevated privs on Cygwin". ### Set ENV to run under Windows Task Scheduler ### export SHELL=/bin/bash export PATH=/sbin:/bin:/usr/sbin:/usr/bin export MAILTO=root # See also /etc/ssmtp/ssmtp.conf export HOME=/root export USER=root # keep going when something fails set +e if [ $# -lt 1 ]; then echo "Usage: run-parts <dir>" exit 1 fi if [ ! -d $1 ]; then echo "Not a directory: $1" exit 1 fi ### Log STDOUT and STDERR since Task Scheduler is not the same as crond. LOGFILE=/var/log/cron.log TMPFILE=/var/log/run-parts.log exec </dev/null >>$TMPFILE 2>&1 # Ignore *~ and *, scripts start_time=`date` for i in $1/*[^~,] ; do [ -d $i ] && continue # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts [ "${i%.rpmsave}" != "${i}" ] && continue [ "${i%.rpmorig}" != "${i}" ] && continue [ "${i%.rpmnew}" != "${i}" ] && continue [ "${i%.swp}" != "${i}" ] && continue [ "${i%,v}" != "${i}" ] && continue if [ -x $i ]; then $i 2>&1 | awk -v "progname=$i" \ 'progname { print progname ":\n" progname=""; } { print; }' fi done end_time=`date` # Merge tmp log with /var/log/cron if [ -s $TMPFILE ]; then echo "Started: $start_time" >> $LOGFILE cat $TMPFILE >> $LOGFILE echo "Finished: $end_time" >> $LOGFILE echo "" >> $LOGFILE : > $TMPFILE fi exit 0 cat <<'EOM' "How to run cron jobs with elevated privs on Cygwin". This procedure has been used with Cygwin running on Vista or Windows 7, 10. # Here is an example of a Linux-style /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts #1 * * * * root run-parts /etc/cron.hourly 02 22 * * * root run-parts /etc/cron.daily 22 22 * * 0 root run-parts /etc/cron.weekly 42 22 1 * * root run-parts /etc/cron.monthly ########################################### The second column (hours) is 4 for Linux, which is fine for servers, but for laptops, values like 0 (midnight) or 22 (10pm) may be more appropriate. Start -> All Programs -> Accessories -> System Tools -> Task Scheduler Task Scheduler: Create Basic Task (do this 3 times) Name: cron-daily, cron-weekly, or cron-monthly Description: Runs cygwin programs with elevated privs. Trigger: Daily, 10:02:00pm, recur every 1 days Weekly, 10:22:00pm, recur every 1 weeks on Sunday Monthly, 10:42:00pm, recur all months on the 1st Action: Start a program Program: C:\cygwin64\bin\bash.exe Arguments: /usr/bin/run-parts /etc/cron.daily or: /usr/bin/run-parts /etc/cron.weekly or: /usr/bin/run-parts /etc/cron.monthly Start in: C:\cygwin64\bin Finish: Open the Properties dialog when finished. General: Run whether user is logged on or not Do not store password Run with highest privileges Conditions: Wake the computer to run this task Settings: Run task as soon as possible after a scheduled start is missed Stop the task if it runs longer than: 1 hour Populate the directories with shell scripts or symlinks to binaries. ln -s /usr/bin/updatedb /etc/cron.daily I used "ln -s /usr/bin/run-parts /etc/cron-parts" so that this file can be easily found using "ls -l /etc/cron*". joeinwap,gmail EOM -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |