Executing a bash script and call python script via crontab

I have exactly the same problem :

What i don't understand it's how to specify path of SHELL=/bin/sh Because i can't move my script from :

/home/ubuntu/folder/monitoring.sh

do I have to specify the path on my script or on the crontab? and how can I retrieve the path?

there's the content of my crontab :

*/1 7-19 * * * /home/ubuntu/folder/monitoring.sh

Content of monitoring.sh

#!/bin/bash
touch testcronsh.txt
python monitoring.py

Actually when i try to execute my script via crontab i have that error :

/bin/sh: 1: root: not found 
5

1 Answer

Okai I have found the solution.

First thing to know i'm a beginner in linux env.

So i have created a monitoring.sh script with chmod 770. this file call an other file named monitoring.py who got chmod 770.

Than i add the monitoring.sh on my crontab.

What i didn't know it's the crontab user isn't the same

So the call of my python script on my .sh script must have the full path

monitoring.sh

#!/bin/bash
touch testcronsh.txt
python /home/ubuntu/folder/monitoring.py 
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like