简体   繁体   中英

ruby OCI script encounters error when run as scheduled task

I have a script that makes queries to an oracle database. When I call the script from the command line all works well and as expected.

However, when I set up Windows Task Scheduler to execute the script I am encountering an error at the point where I require the OCI gem and I'm not sure why:

C:/Ruby21-x64/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': 193: %1 is not a valid Win32 application.   
- C:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/ruby-oci8-2.1.8/oci8lib_210.so (LoadError)

My environment:

64 bit Windows 7

Ruby 2.1.7

ruby-oci8 -v 2.1.8 (the oracle gem)

Oracle Instant Client for 64 bit Windows

I have done some research into what seem to be similar errors and it seems that the problem is related to the gem being built for a 32 bit Windows platform, but I'm not sure what to make of this, especially since it works fine when called from the command line.

Any help is greatly appreciated!

This issue was caused by the PATH environment variable not being updated in the Task Scheduler process. The Task Scheduler process (taskeng.exe) runs in the background even if you close the GUI and open it again. So closing the GUI and opening again does not reboot the process to catch the updated PATH .

When I installed the Oracle Instant Client I had to add it's location to the PATH . But Task Scheduler could not find the client because it needed to be truly restarted to update its known PATH variable.

Solved by killing taskeng.exe and starting it again. (Rebooting the computer will have the same effect.) Thanks to Kubo Takehiro for helping me identify the problem!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM