是否应使用“&"来指定linux cron作业.表示要在后台运行? [英] Should linux cron jobs be specified with an "&" to indicate to run in background?
本文介绍了是否应使用“&"来指定linux cron作业.表示要在后台运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在crontab文件中,应该在命令后加上&",还是在后台运行该命令?
In a crontab file, should commands be specified with a trailing "&", or will the command run in the background anyway?
我有:
*/20 * * * * /home/me/monitor/check.sh /home/me/monitor/check.properties >> /home/me/monitor/check.log 2>&1 &
我在各个地方都看到了这个问题的矛盾答案.有人说不需要放置&",而另一些人说即使所有输出都已重定向,也可以在没有&"号cron的情况下等待命令的输出.
I've seen contradictory answers to this question in various places. Some say no need to put an "&", others that without the ampersand cron waits for output from the command, even though all output is redirected.
推荐答案
由cron运行的每个作业都会自动在后台运行,因此不需要&
Every job that's run by cron is run in the background automatically, so no need for the &
也请参见此.
这篇关于是否应使用“&"来指定linux cron作业.表示要在后台运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文