what is >> symbol and >& in unix/Linux?
I have a CRONTAB entry as below. Can someone tell me what the below statement is exactly doing?
1 0 * * * /vol01/sites/provisioning/MNMS/45627/45627.sh1 >> /vol01/sites/provisioning/MNMS/45627/output/cron.log 2>&1
See What is the difference between > and >> (especially as it relates to use with the cat program)?, What does “3>&1 1>&2 2>&3” do in a script? and of course, your shell's manual. (There are some further explanations in Is this a typo in Bash manual's redirection section? too.)
>redirects output to a file, overwriting the file.
>>redirects output to a file appending the redirected output at the end.
Standard output is represented in bash with number
1and standard error is represented with number
2. They are separate, so the user can redirect them to different files.
2>&1redirects the standard error to the standard output so they appear together and can be jointly redirected to a file. (Writing just
2>1would redirect the standard error to a file called "1", not to standard output.)
In your case, you have a job whose output (both standard and error) is appended at the end of a log file (
cron.log) for later use.