0

I am using putty to login in webfaction server. I used crontab -e command and wrote this line over there and restarted apache. According to this line it would run every minute but even after restarting its not running. But why? I want to run python script if i run it through putty by using python2.7 alerts_test.py it runs perfectly. But using cron it does'nt. Please help. Thanks in advance. My crontab command is below...

* * * * * /home/gbtech/webapps/django/lib/python2.7 /home/gbtech/webapps/django/fortis_django/alerts_test.py

also tried

* * * * * python2.7 /home/gbtech/webapps/django/fortis_django/alerts_test.py
  • Can you try something like `* * * * * touch /tmp/test_file` and see if that file gets created and that its modified time (visible via `ls -l`) gets updated every minute? Just to make sure your crond is functioning properly – abyx Jul 14 '11 at 08:25
  • @abyx yes i tried as you said but this file is not creating at specified location. I think my crontab is not running what i have to do now? –  Jul 14 '11 at 08:28

2 Answers2

1

Couple questions..

  • Did you try placing a MAILTO directive at the top? This would send you all encountered errors.

MAILTO:"mydebugmail@gmail.com"
* * * * * /home/gbtech/webapps/django/lib/python2.7/home/gbtech/webapps/django/fortis_django/alerts_test.py

  • Did you check if alerts_test.py is set to be executable? Perhaps try chmodding it to 755 just in case?

  • Is crond, the cron daemon running?

  • Is there any info in the log, found in /var/log/cron ?

Swader
  • 499
  • 2
  • 5
  • 18
  • I navigate the error in another file it is giving python2.7 is a directory. How python script can run from crontab. It runs by using python2.7 alerts_test.py on putty using webfaction. –  Jul 14 '11 at 10:37
  • If that is the error, it might be that the folder name is confusing it - it might think that everything after the . (dot) is a file extension? – Swader Jul 14 '11 at 12:03
0

It might be because python2.7 not found.If that is the case try to use

* * * * * /usr/local/bin/python2.7 /home/gbtech/webapps/django/fortis_django/alerts_test.py instead

You can use

 * * * * * python2.7 /home/gbtech/webapps/django/fortis_django/alerts_test.py >> /path/to/somefile 2>&1

to see what happened using 'somefile'.

machaku
  • 101
  • 2