Ubuntu新贵使用一个脚本来运行多个其他的脚本

这个脚本将启动服务:

#!upstart description "example.com" author "Geert" script for service in "website" "feeds" "jobs" do exec start service.example.com service=$service done end script 

服务脚本如下所示:

 #!upstart description "service.example.com" author "Geert" start on (local-filesystems and net-device-up IFACE=eth0) stop on shutdown respawn # restart when job dies instance $service script exec /home/fs/.nvm/v0.6.7/bin/coffee /home/fs/Dropbox/work/2012/krafters/$service.coffee end script 

我的问题是,它似乎只是在创build网站服务。

 initctl list | grep example example.com stop/waiting service.example.com (website) start/running, process 22787 

首先,Upstart作业configuration文件(.conf文件)不是传统意义上的脚本:第一行(' #!upstart ')是完全多余的,只能作为注释处理。

你的问题是使用for循环的第一个.conf文件中的' exec ':exec用你给exec的所有参数replace当前运行的shell,所以只有for循环中的第一个条目将被运行。

要解决这个问题,只需在第一个.conf文件中删除' exec '即可。