Re : Pass parameters from Cron job to Java code


 
Thread Tools Search this Thread
Top Forums Programming Re : Pass parameters from Cron job to Java code
# 1  
Old 12-04-2008
Re : Pass parameters from Cron job to Java code

Hello All,

Hope all is fine. I am newbie to Unix. I am using Bourne Shell (sh). One of the question I have is that I am trying to read XML file and based on reading that XML file I want to run same java programs at different hours. When I run the Java code, I wanted to pass parameters to my compiled java code, for example : if I read 4 Apps (App1, App2, App3,App4) from XML and if I read different time to run the same java code for above mentioned parameters (App1,....).then I will have to set cron job at different time but my question is how will I pass parameters from cron job to java code at while running it.

This is what I want to do..............

05 14 * * * java ./program1(App1)
10 14 * * * java ./program1(App2)
15 14 * * * java ./program1(App3)
20 14 * * * java ./program1(App4)


Thanks in advance and appreciate your feedback on this.

Thanking you ,
Sam
# 2  
Old 12-05-2008
Passing parameters to Java is usually done either through the environment. So, set an environment variable, like:
Code:
FOO="Parm1;parm2;parm3" java ./program1
FOO="Parm1;parm2;parm3" java ./program2

I might be wrong on a few details. For instance, maybe you need to pass the variables in with an option like java -d. Here's a link that will help you both on the unix side and in the java side: http://www.rgagnon.com/javadetails/java-0150.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Shell script with Java code in Cron

Dear All, I have a shell script which has JAVA code inside it runs perfectly on command line. But while I set it on cron, all rest of the script runs but Java code doesnt. java -cp... (3 Replies)
Discussion started by: Deei
3 Replies

3. Shell Programming and Scripting

Pass Parameters to awk command

I need to pass values at runtime for the below awk command where l is the length and partial.txt is the file name. awk -v l=285 '{s="%-"l"s\n";printf(s,$0);}' partial.txt > temp1.txt; (5 Replies)
Discussion started by: Amrutha24
5 Replies

4. Emergency UNIX and Linux Support

Pass two parameters

Hi I have a batch file aaa.exe which needs two input parameters: Usually the command's format likes aaa 555 10000 But I want to use parameters to do it. aaa $1 $2 These two parameters come from a text file list.txt 41800497 41801375 41814783 41816135 41814930 41816135 41819987 41820843... (4 Replies)
Discussion started by: zhshqzyc
4 Replies

5. Shell Programming and Scripting

get system date, format it, pass it as a parameter to a perl script - all in cron job

I am trying to get the string containing date - in a specfic format actually, although I think that part is inconsequencial - 1110226^1110226^1110226^1110226^1110226 - through echo or printf or in some other way - created within a cront job and passed as a parameter to a perl script. Now, I know... (3 Replies)
Discussion started by: v8625
3 Replies

6. Shell Programming and Scripting

Pass parameters to function

Hi, for example I have this function: function get_param () { test=echo "some string" test2=echo "someother string" } I want to call this function and get test or test2 result, how do I do that ? Thank you (2 Replies)
Discussion started by: ktm
2 Replies

7. Shell Programming and Scripting

cron job - shell code correction

Hi I have a website that is having problem with cron jobs... I have a cron job set up to go to a page with this code... <? include('config.php'); if($_sys->bible_email_frequency == 'DAILY') { $u = new user(); $u->send_bible_email(); } ?> If i send my browser to this page... (2 Replies)
Discussion started by: whybelieve
2 Replies

8. Shell Programming and Scripting

How to pass parameters transparently into a sub script

Hi, I am trying to write a script like this: #!/bin/ksh #script name: msgflow #The awk commands for Solaris and Linux are incompatible if ] then msgflow-solaris $* elif ] then msgflow-linux $* fi This script is shared by a file system which is visible to both... (3 Replies)
Discussion started by: danielnpu
3 Replies

9. Shell Programming and Scripting

How to pass parameters to an awk file?

I have an awk file where I need to pass a filename and a value as a parameter from a sh script. I need to know how to pass those values in the sh script and how to use the same in the awk file. Thanks in advance!!! Geetha (3 Replies)
Discussion started by: iamgeethuj
3 Replies

10. Shell Programming and Scripting

Terminal And Cron Job Return Different Status Code

Dear All, I want to write a shell script to test the server is running or not. The method is pinging the server and examine the status code. the script: #/bin/tcsh ping -c 3 host if ($? != 0) then actionA endif This script work fine in terminal. The status code is 0 when the... (1 Reply)
Discussion started by: isaac_ho
1 Replies
Login or Register to Ask a Question