From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin@cygwin.com
Subject: Re: Hiding console when running Cygwin utility from Task Scheduler.
Date: Wed, 02 Aug 2017 19:21:00 -0000 [thread overview]
Message-ID: <a547973c-5175-9dc8-1b8a-55635e73983b@SystematicSw.ab.ca> (raw)
In-Reply-To: <86o9ryymx5.fsf@gavenkoa.example.com>
On 2017-08-02 10:06, Oleksandr Gavenko wrote:
> I prepared backup task in Bash script and added task to run it in Windows Task
> Scheduler:
> Executable: c:\opt\cygwin\bin\bash.exe
> Params: c:\home\backup\backup-job.bash
> Each time job run I see console screen. 'procmon' shown that it is::
> \??\C:\Windows\system32\conhost.exe 0xffffffff -ForceV1
> Seems each Cygwin utility brings console into foreground. I also tested with:
> c:\opt\cygwin\bin\yes.exe
> How can I prevent console to be shown when bash started from Task Scheduler?
Redirect all stdin from /dev/null, stdout, stderr to a log file in your script ,
like:
#!/bin/bash
prog=${0##*/}
base=${prog%.*}
log=/var/log/$base.log
# do everything inside this wrapper
{
...
} < /dev/null &> $log
or equivalent on each command if you don't have many.
Ensure you always use the correct hashbang path and the script is executable.
You might also want to change your Task Action Arguments to:
-- /proc/cygdrive/c/home/backup/backup-job.bash
to indicate "--" end of options, there are no options, just args, and use Cygwin
paths for all file arguments.
You may also have to set the (o) Run whether user is logged on or not radio
button, [X] Do not store password..., and [X] Run with highest privileges check
boxes.
I have found it useful to Cygwin symlink all cron/Task scripts to
/usr/local/bin/ and use that path for all script jobs.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
--
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
next prev parent reply other threads:[~2017-08-02 19:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 16:06 Oleksandr Gavenko
2017-08-02 19:21 ` Brian Inglis [this message]
2017-08-02 23:41 ` Oleksandr Gavenko
2017-08-03 5:21 ` Brian Inglis
2017-08-03 11:43 ` Oleksandr Gavenko
2017-08-03 13:05 ` cyg Simple
2017-08-03 14:09 ` Oleksandr Gavenko
2017-08-07 17:05 ` Andrey Repin
2017-08-07 17:36 ` Oleksandr Gavenko
2017-08-08 0:05 ` Andrey Repin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a547973c-5175-9dc8-1b8a-55635e73983b@SystematicSw.ab.ca \
--to=brian.inglis@systematicsw.ab.ca \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).