At work I’ve been tasked with converting a cronjob to run on Ubuntu’s excellent Upstart system. I have to say, Upstart is freaking awesome for someone who’s worked with Node’s event system or anything in Java that has Listener as part of the name.
Creating a job is as simple as placing a configuration file in
start on startup script /path/to/important/script.sh end script
Instead of making your workflow into one massive job, split it into separate files and make them listen for each other. For example, suppose you want to prepare some data from a database (convert it, perhaps) and then upload it to a server:
task script /script/to/prepare/data.sh initctl emit data-prepared end script
start on data-prepared task script /script/to/upload/data.sh end script
This way, you can fire off a series of events and not have to worry.
Our configuration requires that one server be able to touch off events on another.
To do this, we’re using “signal files” so one server SSHes in and
the signal file on the other. Upstart makes this easy too:
task script my-action.sh ssh server-2 "touch /path/to/notify/job-1-done" end