1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Automating cygwin scripts from batch files using windows scheduler

Discussion in 'Windows XP' started by goatherder3, Jan 28, 2011.

Thread Status:
Not open for further replies.
  1. goatherder3

    goatherder3 Thread Starter

    Oct 1, 2004
    I like to automate backups, reminder emails, housekeeping functions, etc, in the unix environment, but I use winXP at home. I've used the cron service to schedule tasks in the past, but this fails if the computer is turned off at the appointed time. In unix, anacron takes care of this, but there is no anacron for cygwin. Thus, I want to use the windows scheduler to run batch scripts that in turn call my old cygwin (unix) scripts. I found the following old thread, but I have had no success with it.... help- I'm so close!


    My problem is the simple-looking line below

    start c:\cygwin\bin\bash.exe -l myscript

    which, as I understand it, should be written into a batch (.bat) file. Then when the file is called, it should fire up cygwin and execute "myscript". On my windows machines at home and at work, I don't get any errors with the above command, however, my scripts do not run.

    I'm also playing with this:


    Please help!
  2. goatherder3

    goatherder3 Thread Starter

    Oct 1, 2004
    ok, I got something that works...

    This was very helpful


    With the following changes to Cygwin.bat (pay attention to the ,,-c "%*",, part)

    $ cat /Cygwin.bat
    @echo off

    chdir C:\cygwin\bin

    bash --login -i -c "%*"​

    I can now do this

    C:\>c:\cygwin\Cygwin.bat cd /home; ./test1.sh​

    where I'm able to run a long list of commands separated by the semi-colon. Also, the batch file runs when double-clicked on, so I think it should work fine when executed form windows scheduler.

    Did I do this the hard way?
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/977597

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice