Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1294 posts
|
Red Hat Linux 6.5
Oracle database 11.2.0.4 Hi, is it possible for a java application to run an import script? For example, I have a button in my Java application, and when I click on it, it is going to start the import. In my case, I have import script which is scheduled on crontab daily. It will read the dump file from a shared filesystem. Please find below the import script export ORACLE_HOME=/oracle/app/products/11.2.0 export ORACLE_SID=RECONDB export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME cd /oldbackup/OTC/gci/movedump date=(date + "%d%m%Y%H%M") arch=$(ls -t | head -1) imp \"/ as sysdba\" file=$arch fromuser=L2TCP touser=OTC log=impgci`(date +"%d%m%Y%H%M")`.log Regards, Roshan |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
5731 posts
|
I recommend you an easy method;
2 steps. write a bash script for doing the import (setting the env and running the impdp command). execute this bash script from your java code. that's it |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1294 posts
|
Hi,
thanks for update. Is it possible to run cronjob on conditional basis rather than periodically? How can I make this cron conditional instead of scheduled(@ 07 15 a.m) Regards, |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1294 posts
|
Can I implement a condition testing in the import script , for example, read a variable from a file and if it is true, the import will start. Else, it will report and error
read n < fileDATA.txt In fileDATA.txt, user will set a value Yes - proceed No - not proceed with import. Y=Yes N=No if [$n ==$Y] then impdp .... else "Echo..." |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
5731 posts
|
Yes. You can do it.
You can write a bash script to read the file, see if the thing that you are looking for is true or false. Then according to the value of that thing, the bash script can run the import job or whatever you want.. This is a basic scripting method. It can be done by standard if-else statements. As for your question about cron, normally cron is a scheduling thing. But you can make it event driven as follows; For example; you can write a cron job to check a value in a file. You can make this cron job run in every second.. (or you can even daemonize it ->while(true) -> run) So this job will check a value in a file, and if it finds it true, it runs whatever code you like. Probably, the event is triggered by another code . When the event happens, this another code should modify that file and set the value, that your cron job is checking, to true. As your cron job is checking the file every moment, it will see the value as true and it will run the code you like.. By using this kind of an approach, may make cron event driven. This is just to show you the way. The approach that I explained above should be enhanced for being a true solution ofcourse.. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
1294 posts
|
Thanks a lot Erman :)
Can you please guide me in setting up the cron 0 22 * * * [ -e /home/oracle/response/Y ] && /home/oracle/response/script.sh In the above example, if file Y exists, script.sh will run. The condition to check the content of file if true will be as follows [oracle@RH-FTTH-DEV-DB1 ~]$ cat imp.sh read n < test.txt echo $n if [ $n == true ] then imp OTC/psk123$ fromuser='OPS$IMCC_5X' touser='OTC' file=export281027.dmp log=import6.log #echo "kkkkkkkk" else if [ $n == false ] then echo "Import cannot start" else cat /dev/null > test.txt echo false > test.txt fi fi How can i setup it in cron? Regards, Roshan |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Administrator
5731 posts
|
You already sent me a cron example. In your example, your cron runs script.sh according to a conditon.
So now you are asking about the crontab entry of your imp.sh script.. your imp.sh script checks its conditions itself internally. So you will just schedule it and it will run. The interval that you will use for this scheduling is up to your choice. You can schedule it to run in every moment, or every hour.. It checks the necessary conditions internally during runtime anyways. I didn't understand what you are asking to me for this ? |
Free forum by Nabble | Edit this page |