2

I have a problem with regards to crontab. I have a script named checker.sh and I want to schedule it so that would run every minute:

* * * * * sh /home/pi/checker.sh

I have the script here: screenshot

The concept of this script came from here: Linux Script to check if process is running & act on the result

The problem is: whenever I end the python process to check if checker.sh can run the python script, it does not work. I don't know where the problem is. I tried to change the path name of python to /usr/bin/python on the checker.sh script itself but still it does not work.

I hope someone can solve this.

0

Use a fully qualified path in crontab ie.

/bin/sh /home/pi/checker.sh
0

You specified bash in the shell script and then attempt to call your script with sh in the crontab. There is really no need to specify the shell in crontab since you specify it in the shebang, so this should work just fine:

* * * * * /home/pi/checker.sh
  • i have tried this also but still it does not work. :( – frianne12 Jun 20 '15 at 6:37
0

Try explicitly navigating to the directory within the shell script itself using cd and the complete path. I had a similar problem and fixed it by doing that. For example, at the top of your script after #!/bin/bash you would put:

cd /home/pi/Some_Directory`
# the rest of your script
0

This seems to be a relatively old question, but I believe the problem is with the header (Shebang). Your script has the following header:

#! /bin/bash

However, it should be:

#!/bin/bash 

That is, without spaces between #! and /bin/bash. This has happened to me before and removing the space solved it.

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.