delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/30/23:58:11

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: <433E0942.6040507@byu.net>
Date: Fri, 30 Sep 2005 21:57:54 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Mike Dieter <quincunx12252000 AT hotmail DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: 2 cron problems and 1 solution on XP
References: <BAY101-F3581BC3AAEF50AA00A4F69CA8E0 AT phx DOT gbl>
In-Reply-To: <BAY101-F3581BC3AAEF50AA00A4F69CA8E0@phx.gbl>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Mike Dieter on 9/30/2005 9:35 PM:
> So next I tried only escaping the percent sign AND IT WORKED!
> 10 9 * * 1-5 /home/Gary/MCD.send --subject "`date +\%B` Clearance" 2>&1
>> /dev/null &

Well, yeah - isn't that what 'man 5 crontab' said?  "Percent-signs (%) in
the command, unless escaped with backslash (\), will be changed into
newline characters, and all data after the first % will be sent to the
command as standard input."

> This might just be my ignorance but I do all my crontabs like the above,
> ie, 2>&1  > /dev/null &
> to prevent cron mailing me with these error messages AND IT STILL DOES!

Here, the clue is in 'man bash': "Note that the order of redirections is
significant.  For example, the command 'ls > dirlist 2>&1' directs both
standard output and standard error to the file dirlist, while the command
'ls 2>&1 > dirlist' directs only the standard output to file dirlist,
because the standard error was duplicated as standard output before the
standard output was redirected to dirlist."  In other words, until you get
the order correct, your crontab is still generating output, and once
output is generated, cron sends mail.  You could also do 'ls >/dev/null
2>/dev/null' to be explicit that you want to ignore both outputs.

> Finally, is & necessary?  Or are there times when it still is good to have?

Cron already runs as a daemon, so putting something into the background
doesn't really do much for you, since it is not blocking an interactive shell.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDPglA84KuGfSFAYARAnXMAJ9VDsx6SObSx03VmeRjiRt9mkairwCeK3pZ
h/zC/72tXGFcEbb9XofXzfY=
=QhjT
-----END PGP SIGNATURE-----

--
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