Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Fact: If you use start on <event> for a job, your job might be run every time <event> occurs. The upstart cookbook mentions two methods to run a job only once.

The first is logical to me, and involves creating a dummy run-forever job that is started on <event>. Since that dummy job is run-forever, and single-instance, it will get started only once and you can use start on started <dummy-job> in your actual job.

The second method looks a lot simpler: start on startup and <event>. The purpose of this question is to understand why this second method works. This has to do with understanding how on start handles events compounded by and. I.e., since <event> occurs multiple times, why is it that the compounded event is triggered only once? Could it be that a compounded event is re-triggered only after both startup and <event> are re-triggered? I'm looking for a confirmation of this.

share|improve this question

2 Answers 2

I will share my findings, which give an empirical answer to my question.

I tested using 2 events, desktop-session-start and net-device-up and indeed it seems that the compounded event desktop-session-start and net-device-up is only triggered when each of the events has been triggered.

Specifically, I get the event the first time I log into ubuntu, after the network has come up (dhcp completed). Then if I toggle networking, I don't get the event. Likewise, if I log out/log in, while networking stays connected, I don't get the event. I only get it when I log in and networking has been down since last triggering, or analogously, when I bring the interface up after I have logged out, since last triggering.

share|improve this answer

The expression event-a and event-b is only true once BOTH event-a and event-b have been emitted, and if your job runs, then BOTH events have to be emitted again to be true.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.