38

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
2

2 Answers 2

61

> 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 1 and standard error is represented with number 2. They are separate, so the user can redirect them to different files.

2>&1 redirects the standard error to the standard output so they appear together and can be jointly redirected to a file. (Writing just 2>1 would 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.

For additional info, check the bash manual (section "Redirection"), this question, and this question.

9

You should google with keyword bash redirection for some detailed information. Here is a nice article for reference.

For your question, the crontab will run 45627.sh1 scripts at 00:01 everyday and append its error and output to the cron.log file.

1
  • Thanks a lot. It really helps. Now I understood Google can't give everything. Experts advice always best :)
    – user3475
    Sep 4, 2013 at 12:54

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