1

I want to create a cron job that will run redis every 30 minutes if it is not already running, but I don't know what I should do.

I know that the beginning should look like this */30 * * * */<some path to redis-server file>.

I want to create this cron job because its get a little tedious running redis via ./redis-server every time it crashes.

I figured out it was crashing because my memory usage was a bit over the limit. Thanks for your help.

6
  1. Redis shouldn't be crashing. I'd focus on that first. Is it running out of RAM?
  2. Use something like Supervisor or Monit, or run Redis through something like Upstart.
  • I am sort of familiar with supervisor as I am using it to run celery. How would I run redis with this method? Would I let the command=./<path>/redis-stable? – PiccolMan Aug 31 '15 at 22:51
  • Yeah use supervisor or runit to keep it going. – Matt Aug 31 '15 at 23:04
  • xkcd.com/1495 – Kroltan Sep 1 '15 at 3:56
1

The answer that focusing on why it's crashing is the right thing to do. For future reference if someone is looking for a way to cron a check for an app running and start it if it's not, I've always done so with a bash script. For example:

#!/bin/bash

# Check if httpd is running
if pgrep "httpd" > /dev/null
then
    echo "Running"
else
    /etc/init.d/httpd start
fi

Then you can cron the bash script even every minute. That's the simple version. I'd also suggest logging the restarts to a script to help you track down when your application is crashing so you can review logs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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