You can define a simple task job that start on event of your choice, run your script and at the end emit event to start the other two job.
For example:
# mainJob -
#
# This service emit myEvent to run firstJob
description "emit myEvent to run firstJob"
start on runlevel [2345]
task
console log
script
echo "(startTask) $UPSTART_JOB -- $UPSTART_EVENTS"
exec /path/to/your/script
initctl emit -n myEvent
end script
In order to do not modify upstart script of the other two jobs, you should override files that allow you to modify the way in which a job starts and stop by modifying the start on and stop on conditions.
Following my examples I created a simple firstJob.conf
like this:
# firstJob -
#
# This service print environment variable
description "print environment variable"
start on runlevel [2345]
stop on runlevel [016]
task
console log
script
if [ "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" -o "$RUNLEVEL" = "6" ]; then
exec echo "(stopTask) $UPSTART_JOB -- $UPSTART_EVENTS"
else
exec echo "(startTask) $UPSTART_JOB -- $UPSTART_EVENTS"
fi
end script
And then I override start on condition creating override file:
echo "start on myEvent" > /etc/init/firstJob.override
So firstJob
will start on myEvent
generated by mainJob
and stop on runlevel [016]
I tested these jobs on lubuntu 12.04 and after reboot I found in /var/log/upstart/firstJob.log
:
(startTask) firstJob -- myEvent
You should check if "the other two jobs" need particular event condition to start and be sure that mainJob
start on these events.