Square brackets and

I'm trying to add a new entry into crontab, the issue I have is that all other entries are written like so:

0 0 * * * [ -x /home/test/test_reports/nightly ] && /home/test/test_reports/nightly

What is the purpose of [ -x /home/test/test_reports/nightly ] ?

I tried to Google it but with no luck..


The options within [ ] can be found in man test :

-x FILE

FILE exists and execute (or search) permission is granted

So what these lines are doing is to check if the file is executable (and of course if it exists) and, if true, execute it.

链接地址: http://www.djcxy.com/p/97052.html

上一篇: 用或不用导出定义一个变量

下一篇: 方括号和