简体   繁体   中英

upstart: echo in script

in my upstart script (Ubuntu 12.04.2) I have the following:

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

The problem is that /tmp/000 is there but none of the other files in /tmp. So it seems after the echo the script stops.

How to rewrite the line with the echo so the script does not stop?

Thanks!

Replace all the exec's with the following:

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

The command exec replaces the current process with, in your case, the touch command in line 1. Afterwards there is no shell any more to return.

Answer: explaining the exec command.

Try your script without the exec's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM