Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle error in Task Scheduler

We have a C# program which is scheduled to run in Task Scheduler on Windows Server 2003, designed to delete out-of-date files in a folder based on information drawn from multiple Oracle databases. I can execute the application manually and everything works fine - logged in either as myself with administrative rights, or logged in as the assigned task user which has Users rights.

When the task user is logged off the machine, though, the application fails on each database with one of two errors: either

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

or

ORA-12154: TNS:could not resolve the connect identifier specified.

All of these databases are using a connect string (retrieved from another, SQL Server, database) which, as I stated before, connect and run just fine when operated manually. I have been all over the web looking for tips which might apply to this circumstance and have not come up with a definitive answer.

Is there anyone reading this message who might know the answer to this problem? Any suggestions are most welcome.

like image 959
Mike Preston Avatar asked Dec 27 '11 20:12

Mike Preston


2 Answers

What user is your scheduled task set to execute as? One of the same users you tested as, or another account?

Regardless, it doesn't sound like a permissions issue, as much as the ORACLE_HOME environment variable not being set. (It looks like your program is probably trying to connect through a tnsnames.ora file that can't be found.) You may need to have the scheduled task first launch a batch file that sets the environment, then continues to call your C# program.

like image 176
ziesemer Avatar answered Oct 06 '22 00:10

ziesemer


I had similar issues, but with some java app. The same happened - manual task execution was fine, but automated execution always failed (same account!).

Check with your admin (or maybe you can do it yourself) and set your C# app to be executed by the admin account (testing only!) or see whether there are any other scheduled tasks and interrogate them to see which windows account they use and how it's set up. I remember that we (I + admin) had to experiment a bit, but finally he created a new privileged account (a copy of some other existing one) to execute the scheduled task.

like image 37
damo_inc Avatar answered Oct 06 '22 02:10

damo_inc