Motion - Shell Keep Alive Script

Shell Keep Alive Script


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/ >/dev/null 2>&1

So name this script "" 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 ]
 echo "Motion not running, re-starting it"
 echo "Motion is running."

exit 0

Comments and Bug Reports

RelatedProjectsForm edit

ProjectSummary Simple shell script called from cron that checks and keeps motion running
ProjectStatus Stable
ProjectSubmitter Anon Dude
Topic revision: r2 - 21 Dec 2005, KennethLavrsen
Copyright © 1999-2023 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.