# How do I do that?



## dennis218 (Jul 8, 2012)

Hello *I* need an automatic restart script, that restarts a service if the process is not there.

At the moment *I* start the process over [cmd=]screen -dmS "NAME" "DATA"[/cmd]

Please help me *I*'m a newbie in this section.


Sorry for Bad English


----------



## izotov (Jul 13, 2012)

Could you please a little bit better describe what you want to do? What do you mean "restart a data"?


----------



## SirDice (Jul 13, 2012)

Have a look at sysutils/daemontools.


----------



## fluca1978 (Jul 16, 2012)

Does not sound a very complex task to do with a shell script, that can be scheduled itself.
Something like the following can do the trick, if the context is simple:


```
#!/bin/sh                                                                                  


PROC_NAME="myproc"

while :;
do

    pgrep $PROC_NAME > /dev/null

    if [ $? -ne 0 ]
    then
        echo "Restarting process $PROC_NAME"
    else
        echo "Process $PROC_NAME running!"
    fi

    sleep 5
done
```

But without information it is quite difficult to understand what is your aim.


----------

