linux cron 作业是否应该用“&”指定以指示在后台运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10503433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:14:16  来源:igfitidea点击:

Should linux cron jobs be specified with an "&" to indicate to run in background?

linuxcron

提问by user265330

In a crontab file, should commands be specified with a trailing "&", or will the command run in the background anyway?

在 crontab 文件中,是否应该使用尾随的“&”指定命令,还是该命令会在后台运行?

I have:

我有:

*/20 * * * * /home/me/monitor/check.sh /home/me/monitor/check.properties  >> /home/me/monitor/check.log 2>&1 &

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 会等待命令的输出,即使所有输出都被重定向。

采纳答案by Levon

Every job that's run by cron is run in the background automatically, so no need for the &

cron 运行的每个作业都会在后台自动运行,因此不需要 &

See thistoo.

也看到这个