delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/01/09/21:51:29

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
X-Cloudmark-SP-Filtered: true
X-Cloudmark-SP-Result: v=1.0 c=1 a=qXHbJdOSgogA:10 a=kCKDY91tEBMc+hi4YtGk8Q==:17 a=YYmOOrTeCQBRz4P-sroA:9 a=QZ-aw7AauooCVaBH64d_yuM4JoIA:4
Message-ID: <4B494098.4040706@monai.ca>
Date: Sat, 09 Jan 2010 18:51:04 -0800
From: Steven Monai <steve+cygwin AT monai DOT ca>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: question with cygwin.bat and Windows Scheduler
References: <27094829 DOT post AT talk DOT nabble DOT com>
In-Reply-To: <27094829.post@talk.nabble.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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

On 2010/01/09 5:36 PM, aviate wrote:
> 
> Hi...tried for a long, long time trying to make this work to no avail...and
> did not find help online.
> 
> Using Windows XP, I am running a bash script via the windows task scheduler,
> which is calling Cygwin.bat ...The command being tasked is:
> 
> C:\cygwin\Cygwin.bat /myfolder/myscript.sh

You're using 'Cygwin.bat' in a way it wasn't meant to be used.
'Cygwin.bat' is for opening an interactive shell in a Windows console
window, not for running arbitrary bash scripts.

Instead, create a separate .bat file to run your bash script. The
following two-liner should do the trick:

@echo off
C:\cygwin\bin\bash.exe --login -c "/myfolder/myscript.sh"

Name the file something like "myscript.bat", and schedule it to run in
Task Scheduler. Now every time it runs, a console window will open, and
within it you'll see your bash script's output. The window will
automatically close when the bash script exits.

Finally, you may want to look into using Cygwin's 'cron' package instead
of Task Scheduler. One benefit of using cron is that you won't get a
console window popping open every time the script runs.

HTH,
-SM
--

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

- Raw text -


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