I have a queue script that finds new jobs from the db every second and handles them. Sometimes it doesn't do anything for 10 hours, and sometimes it receives 1000 new jobs in 3 min. The queue works fine, mostly.
It needs restarting though. (I'm not entirely sure why. I think other services the jobs talk to don't like connections being open for a long time. Restarting the queue, resets all connections. Maybe that's not why.) And sometimes the queue script just dies. Maybe memory error, I can't pinpoint it.
There's 2 ways to restart that I'm both fine with, (but it has to be automatic):
- Explicitly restart it every 24h:
- Wait until it dies, and start it again
I'm not sure about either... The queue runs in a
screen so I can follow output when I want. How can one command listen for another command to finish and restart it, without being a daemon?
I can't install anything. It's a crappy Redhat server that I don't have decent admin access to.
I've thought about creating a cronjob that fires every 24h and kills itself after 24h, but that just sounds so wrong... I can't use the cronjob for the queue, because new jobs must be executed almost-instantly.