新贵:脚本中的回声

时间:2014-09-23 06:50:37

标签: ubuntu upstart

在我的upstart脚本(Ubuntu 12.04.2)中,我有以下内容:

exec touch /tmp/000
exec echo "ds1307 0x68" >  /sys/class/i2c-dev/i2c-3/device/new_device
exec touch /tmp/111
exec hwclock --rtc=/dev/rtc1 --hctosys  
exec touch /tmp/222

问题是/ tmp / 000在那里,但/ tmp中没有其他文件。所以似乎在回声之后脚本停止了。

如何使用echo重写行,以便脚本不会停止?

谢谢!

2 个答案:

答案 0 :(得分:2)

用以下内容替换所有exec:

script
  touch /tmp/000
  echo "ds1307 0x68" >  /sys/class/i2c-dev/i2c-3/device/new_device
  touch /tmp/111
  hwclock --rtc=/dev/rtc1 --hctosys  
  touch /tmp/222
end script

答案 1 :(得分:0)

在您的情况下,命令exec替换当前进程 第1行中的touch命令。之后不再有shell返回。

Answer: explaining the exec command.

尝试没有exec的脚本。