What is wrong with my python script and cron job?
<p>I have this python script to check services like MySQL and Apache and if some of them are down then it starts again:</p>

<pre><code>import subprocess
import smtplib

_process = ['mysql', 'apache2']
for _proc in _process:
    p = subprocess.Popen(["service", _proc, "status"], stdout=subprocess.PIPE)
    output, err = p.communicate()
    print "*** check service "+_proc+" ***\n"
    if 'Active: active (running)' in output:
        print _proc+" is working!"
    else:
        print "Ouchh!! "+_proc+" again is down."
        output = subprocess.Popen(["service", _proc, "start"])
        print "*** The service "+_proc+" was restarted ***\n", output

        print "*** sending email ***\n"
        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.ehlo()
        server.starttls()
        _from = "from@email.co"
        _to = "to@email.co"
        _cc = ["another@email.co"]
        _pass = "xxxxxx"
        server.login(_from, _pass)
        msg = "\r\n".join([
            "From: "+_from,
            "To: "+_to,
            "CC: "+",".join(_cc),
            "Subject: Ouchh!! "+_proc+" again is down.",
            "",
            "Again " + _proc + " is down. The service was restarted!!"
        ])
        server.sendmail(_from, _to, msg)
        server.quit()
        print "*** email send ***\n"
</code></pre>

<p>It works fine in my console when I execute the below command:</p>

<blockquote>
  <p>python /home/check-services.py</p>
</blockquote>

<p>Everything looks okay. I try setting up the cron job in the webmin server and it should execute every minute but it doesn't. This is the cron's log:</p>

<p>(root) CMD (python /home/check-services.py) every minute, like we already was configurated.</p>

<p>I don't see anything abnormal but it's still no working. I appreciate all your help.</p>

<p>Python version 2.7.</p>

<p>EDIT:
I just saw the email in /var/email/root and it show this:</p>

<pre><code>Traceback (most recent call last):
  File "/home/check-services.py", line 77, in &lt;module&gt;
    p = subprocess.Popen(["service", _proc, "status"], stdout=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
</code></pre>