Experiment: with job-2

Now we bring in our own script, /etc/init/job-2.conf:

Example 5.  job-2.conf

# job-2 - job that delays 3 until 1 has run
description     "job that delays 3 until 1 has run"

#
# Long description:
# This job is ours, and we use it to make job-3 wait for job-1
# even though job-3 itself doesn't know it should wait for job-1
#

start on (starting job-3 and started job-1) 1

author "Jurjen Bokma <j.bokma@rug.nl>"

task

script
echo "Script being run"|logger -t "job-2"
end script
	

1

This is the line that specifies that this script should run whenever job-3 is in the starting state, but only when job-1 is in state started. The effect is that job-3 never starts until job-1 has been started.


jurjen@host:~$ ls -1 /etc/init/job-*.conf
/etc/init/job-1.conf
/etc/init/job-2.conf
/etc/init/job-3.conf
jurjen@host :~$ sudo ./init-order-test
za mrt  5 10:42:33 CET 2011
Output of this run is in syslog.tail and messages.tail
za mrt  5 10:44:08 CET 2011
jurjen@host :~$ cat messages.tail
Mar  5 10:42:33 cit-zb-39-115 init-order-test: Just triggered job-3, will sleep for 90 seconds
Mar  5 10:44:03 cit-zb-39-115 init-order-test: Just triggered job-1
Mar  5 10:44:03 cit-zb-39-115 rsyslogd: [origin software="rsyslogd" swVersion="4.2.0" x-pid="2259" x-info="http://www.rsyslog.com"] rsyslogd was HUPed, type 'lightweight'.
Mar  5 10:44:03 cit-zb-39-115 job-2: Script being run
Mar  5 10:44:03 cit-zb-39-115 job-1: Script being run
Mar  5 10:44:03 cit-zb-39-115 job-3: Script being run

This time, job-1 runs first, before job-3, as we intended, even though job-3 was started 90 seconds earlier than job-1.