2

I have a python script that runs another python script. that 'other script' (script being run) takes ~ 45[min] to complete.

When the 'execution' script is run from Ubuntu's shell, it all works perfectly.

I added an entry to cron to run the 'execution' python script. It seems to run at first, but the program is terminated after a few seconds:


user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 109 1.0 14380 10692 ? R 23:48 0:01 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8029 0.0 0.0 3320 788 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 100 1.1 15448 11900 ? R 23:48 0:07 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8033 0.0 0.0 3320 788 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 97.2 1.2 15992 12412 ? R 23:48 0:11 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8035 0.0 0.0 3320 792 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
user 8037 0.0 0.0 3320 792 pts/1 S+ 23:48 0:00 grep --color=auto python

any idea what I might be missing? I tried to replace the script that is being triggered by the 'execution' script, and have it call a simple script that just does the following:

while(1):
....print "hi"

and it still does not work.

Any ideas? thanks.

(I am using Ubuntu 10.04 LTS)

Prof. Falken
25.1k20 gold badges105 silver badges179 bronze badges
asked Dec 20, 2010 at 5:26
3
  • 2
    Can you post your python script and the cron file here? It'll be more clear in that way Commented Dec 20, 2010 at 5:31
  • Also check logs to see if there is any error (and post error message) Commented Dec 20, 2010 at 5:33
  • 2
    And make sure that (a) either your cron entry invokes python or there is a correct shebang, and (b) the permissions are right. You could also try using logging to try to get it to explain what's wrong. Commented Dec 20, 2010 at 5:39

1 Answer 1

8

There are usually a few common misunderstandings made when trying to run things from cron.

  • There is no session. If you have code that needs a session you have to do additional setup.
  • The PATH and other environment variables are almost always different between your user session and the cron execution environment.

When cron fails it will by default attempt to send mail. You can look in your local mail box or queue (if your mta is down) for errors.

answered Dec 20, 2010 at 6:02
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I have an email account defined in Evolution. But I have never received an email from 'cron' -- how can I set it up? also, what do you mean by "mta is down"? would be happy to learn from you. thank you.
I recommend using the "man" command on your system. man crontab; man 5 crontab; man cron; man 8 cron. Those commands should help you understand what cron is doing and what configuration options are open to you. MTA stand for Mail Transfer Agent. Google is your friend for finding out about MTAs.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.