• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

Crontab question: can not invoke Python script

Hi experts,

I have two Python scripts "A" and "B". In "A" I use "os.system(...)" to invoke script "B". If I manually run "A", then "B" can be invoked successfully. However, when I use crontab to execute "A", "B" does not run in this case.

Anybody knows how to fix this?

Thanks so much.
  • 2
1 Solution
Roger BaklundCommented:
How are you calling B from the os.system() call? Just with "./B.py <params>" or with "python B.py <params>" or similar? When running with cron, it might be necessary to use a full path to the python executable: os.system("/usr/bin/python B.py <params>").
davidw88Author Commented:
hi cxr,

thanks for your reply. I used

command = ("python %s") % (B.py)

Following your suggestion I have added full path to the python executabe. so let's wait and see how it works.

davidw88Author Commented:
It does not work.

I just combined the two scripts into one script. This solved the problem.

Thanks cxr for your reply. Appreciated.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now