Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a Python script that i want to restart if it crashes. So i created a Bash starter script that starts and restarts the Python script in /usr/local/bin/starter

Here's the starter script:

#!/usr/bin/env bash
until myPythonScript; do
    sleep 1s;
done

This starter script i run @reboot (cronjob).

My Python script is also located in /usr/local/bin/myPythonScript so i can start it just by typing myPythonScript.

Now is my problem that i receive the error message that my /usr/local/bin/starter can't find the command myPythonScript. Does anybody know why and how i could solve this.

share|improve this question

migrated from serverfault.com Sep 18 '13 at 13:40

This question came from our site for professional system and network administrators.

add comment

1 Answer 1

up vote 2 down vote accepted

Use the full path. If you are using a crontable, cron does not have the same env, including path, that you do.

You might also consider inittab. It can ensure processes are running and restart if they are not present.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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