I have a python application that uses getopt () to parse the command line for parameters. It works fine in an interactive bash shell or in a bash script that is invoked from the command line; its bit will not be executed when called from a bash shell via cron. I am using Fedora 15.
The application is invoked on invocation as a cron job, causing the following error in / var / log / messages:
myscript.py: abrt: detected unhandled Python exception in myscript.py
It seems that command line options are not being passed to the python script properly.
For example, the following command line call works correctly by setting the input file name to "input.txt" and setting the "log" and "timer" flags to the desired values:
python myscript.py -i input.txt --log --timer
When I try to invoke a program using a bash script on the command line, the bash script works fine. But when I try to run the bash script via cron, the execution fails with the above error.
I find it difficult to determine why the shell script is not executed properly through cron. I use the full path names from the bash script used to set the cron, so the environment paths should not be a problem:
/usr/bin/python /path/to/myscript.py -i /path/to/input.txt --log --timer
I think this syntax, when used in a bash script called via cron, can pass script parameters to python, not myscript.py.
Any help would be appreciated!
source
share