2

I'm looking at a cron file that has the following line:

35  0 * * * /bin/csh -c "/home/abc/.cshrc;/home/abc/appTools/bin/xxx.pl >>& /home/abc/appTools/log/xxx.cronlog"

Is this another form of redirecting STDOUT and STDERR, like 2>&1 ? Is there any difference between >>& and 2>&1 ? This command seems to be working, unless xxx.cronlog does not already exist.

  • 1
    csh and bash have slightly different I/O redirection formats....notice this is a csh command. – mdpc Feb 1 '16 at 20:46
  • Yes, that is why I tagged it "/csh". – Bruce Calvert Feb 1 '16 at 21:01
5

I don't even csh, but the manpage says that it's the same thing like &>> in bash and family—that is open for appending (the >>) and also redirect stderr instead of just stdout.

The forms involving '&' route the diagnostic output into the specified file as well as the standard output. name is expanded in the same way as '<' input filenames are.

http://linux.die.net/man/1/csh:

The forms involving '&' route the diagnostic output into the specified file as well as the standard output. name is expanded in the same way as '<' input filenames are.

>> name

>>& name

>>! name

>>&! name

Like '>', but appends output to the end of name. If the shell variable noclobber is set, then it is an error for the file not to exist, unless one of the '!' forms is given.

  • Thanks for the bang (!) hint. That may solve my problem. – Bruce Calvert Feb 1 '16 at 21:00
  • No need to thank me. Just make sure you accept the answer so that I can get my green points. :D – PSkocik Feb 1 '16 at 21:02
  • 1
    The bang (!) does make sure the redirection ">>&" always writes out the log file, even if the file does not exist. Otherwise, the cron would not execute. One very old bug fixed... – Bruce Calvert Feb 1 '16 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.