Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, January 2008
Problem running Qt console app from cron


Message 1 in thread

Hi,
I have created a Qt console app that does some calculation on an
Oracle database. It runs from a Linux box. It needs to run once every
hour, so cron is the obvious choice. However, when the application is
run from cron, I get the following error:
QSqlDatabase: QOCI driver not loaded
QSqlDatabase: available drivers: QSQLITE QOCI8 QOCI
Could not open database:
    "Driver not loaded"

The last part is my debug output from the program.

Usually if cron jobs does not work because the environment is not
correct. I have tried setting the QTDIR environment variable, but it
makes no different. I had my program print
QLibraryInfo::location(QLibraryInfo::PluginsPath) and it prints the
correct location (/usr/local/Trolltech/Qt-4.3.3/plugins).

Does anybody have any suggestion.

Thanks
Marius

--
 [ signature omitted ] 

Message 2 in thread

On Jan 30, 2008 11:10 AM, Karl-Heinz  Reichel <khReichel@xxxxxx> wrote:
> Hi,
> regard three questions
> under which account is the cron job running?
> Is that user account allowed to access the plugin directory?
> Is that user account allowed to run the according plugin?
>
> regards
> karl-heinz
Karl-Heinz,

Thanks for the reply. I should have mentioned that the application
runs fine for the same user if done from the command line. That would
make the answer yes to all your questions.


Marius

--
 [ signature omitted ] 

Message 3 in thread

On Wednesday 30 January 2008 10:22:55 Marius Roets wrote:
Does it work if you wrap it in a shel script?
Maybe cron does not have the same environment settings/shell as a console?
Did you compare the env settings from cron with a 'normal' shell?
Just a thought.

> On Jan 30, 2008 11:10 AM, Karl-Heinz  Reichel <khReichel@xxxxxx> wrote:
> > Hi,
> > regard three questions
> > under which account is the cron job running?
> > Is that user account allowed to access the plugin directory?
> > Is that user account allowed to run the according plugin?
> >
> > regards
> > karl-heinz
>
> Karl-Heinz,
>
> Thanks for the reply. I should have mentioned that the application
> runs fine for the same user if done from the command line. That would
> make the answer yes to all your questions.
>
>
> Marius
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/


--
 [ signature omitted ] 

Message 4 in thread

Hi,

> Usually if cron jobs does not work because the environment is not
> correct. I have tried setting the QTDIR environment variable, but it
> makes no different. I had my program print

Indeed problems with cron jobs are usually related to environment variables 
being reset. In your case it could be LD_LIBRARY_PATH not pointing to the path 
of database client libraries (if these are shared libraries).

Here is a suggestion to check whether the above applies to your case:
Try printing all environment variables from a cron job. Then reset environment 
variables in your interactive session accordingly. What happens?

--
 [ signature omitted ] 

Message 5 in thread

Thanks for all the replies.
The problem was the LD_LIBRARY_PATH environment variable. It points to
the oci shared library which is needed by the Qt OCI plugin.

Thanks
Marius

On Jan 30, 2008 11:45 PM, Dimitri <dimitri@xxxxxxxxxxxxx> wrote:
> Hi,
>
> > Usually if cron jobs does not work because the environment is not
> > correct. I have tried setting the QTDIR environment variable, but it
> > makes no different. I had my program print
>
> Indeed problems with cron jobs are usually related to environment variables
> being reset. In your case it could be LD_LIBRARY_PATH not pointing to the path
> of database client libraries (if these are shared libraries).
>
> Here is a suggestion to check whether the above applies to your case:
> Try printing all environment variables from a cron job. Then reset environment
> variables in your interactive session accordingly. What happens?
>
> --
> Dimitri
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ]