python Cronjob not running

Status
Not open for further replies.

Ryan Beall

Dabbler
Joined
Mar 8, 2014
Messages
26
I have a python script that is supposed to run every weekday at 1200 and I've set it up and enabled it in the cron tab. I've tested it manually through python as the root use as well as clicking on "run now" and it works. It's only not working automatically? Thoughts?

The scripts sends out an smtp sms email text to my phone based on the status of a website.
 

dewie

Cadet
Joined
Jan 5, 2015
Messages
5
Check your paths, the cron doesn't have your profile

so python must be /usr/bin/python ed
 

Ryan Beall

Dabbler
Joined
Mar 8, 2014
Messages
26
Yeah python isn't in: /usr/bin/

Can I add the path to something or do I have to install it here?
 

dewie

Cadet
Joined
Jan 5, 2015
Messages
5
Login to your server with ssh
and type: which python
This should give you the path

Relative paths wont't work unless you load your profile or env by hand
 

Ryan Beall

Dabbler
Joined
Mar 8, 2014
Messages
26
which python returns:
/usr/local/bin/python

what's the best way to resolve this? uninstall reinstall? move the folder? not too familiar with exactly how the "install" dependancies work in Freebsd. I'm tracking your solution to my problem, i'm just having issues finishing it off. Thanks for helping the noob
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
What does your script look like, and how exactly are you configuring the cron job? If it's properly formatted, it'll start with a line like:
#! /usr/bin/python

Change it to
#! /usr/local/bin/python
 

Ryan Beall

Dabbler
Joined
Mar 8, 2014
Messages
26
I liked your #! idea. I added it and it is still doing the same thing (Nothing).

Like I said. If I run the script manually it works fine and then if I test the implementation using the cron "run now" option it also works. It's just not running automatically. Ideally I'd want this to run once a day. Right now I have it set at 20:12 because I've been testing it.

The script uses mechanize to parse a webpage and smtplib to send an email. It has a while loop that runs until the website give appropriate response or a maximum of 12 times through the loop with a 5 min pause between every check.

http://postimg.org/image/5wkqzj13f/
 

Ryan Beall

Dabbler
Joined
Mar 8, 2014
Messages
26
Status
Not open for further replies.
Top