This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 2 cron problems and 1 solution on XP


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]