Motion - Shell Keep Alive Script

Shell Keep Alive Script

Introduction

Simple shell script called from cron that checks and keeps motion running.

Detailed Description

In my setup I call this script every 5 minutes with a cron line like this:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /root/five-minutes.sh >/dev/null 2>&1

So name this script "five-minutes.sh" and don't forget to set it's permissions to 755 (do a chmod 755).

The reason I look for "./motion" is that I have two running versions of motion, the other one isn't all that important to me right now.

The "restart-motion" script is a simple script that changes to a special directory where I store my latest compiled version of motion and starts it from there, you can do what you want and/or just start motion directly from this script.

Here's the script:

#! /bin/sh

# check that motion is running every 5 minutes

# result is zero if we find it running

ps -F | grep "\./motion"
if [ $? -ne 0 ]
 then
 echo "Motion not running, re-starting it"
 /root/restart-motion
 else
 echo "Motion is running."
fi

exit 0

Comments and Bug Reports


RelatedProjectsForm edit

ProjectSummary Simple shell script called from cron that checks and keeps motion running
ProjectStatus Stable
ReleaseVersion
ProjectSubmitter Anon Dude
Topic revision: r2 - 21 Dec 2005, KennethLavrsen
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.