I have about 5 or 6 ruby scripts I want to run, right after each other. These are all on my local machine (OS X) and won’t be run on a server.
Each takes about 15 minutes to run, and I don’t want to have to wait for each one to finish before running the others manually.
Without using something as heavy as delayed_job or some other queueing gem, how can I achieve this?
Or should I go through the hassle of setting up sidekiq or something else?
Thanks.
P.S. It would be nice to restart the script if one of them times out (I am doing web crawling, so keeping an HTTP connection open sometimes gives me issues) – which happens occasionally.
As Zabba said, writing a script to call your scripts is a good solution. You could write a simple Bash script for this, or use Ruby as shown below:
This uses the
systemcall in Ruby, and$?is the Process::Status object that you can use to capture the exit codes of your scripts.For this to work properly, you just need to make sure that your scripts return an exit code (using the
exitcommand) of0when successful, or something non-zero, e.g.1on failure.There are some obvious security concerns running
system, so unless you’re on your local machine set your permissions accordingly 🙂