Java command in rc.local


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Java command in rc.local
# 1  
Old 10-31-2011
Java command in rc.local

Hi, I hope this is in the right place.

I am trying to get a java command to execute with nohup in the rc.local file. When I remove the nohup it works fine. I need this to run without puTTy open.

This is the command that works:
Code:
cd /home/powvets/public_html/bin/luceneserver/;/usr/local/jdk1.6.0_26/bin/java -Xrs -jar ktlucene.jar&

this one doesn't:
Code:
nohup cd /home/powvets/public_html/bin/luceneserver/;/usr/local/jdk1.6.0_26/bin/java -Xrs -jar ktlucene.jar&

Says it can't find the file

This one doesn't work either:
Code:
nohup "cd /home/powvets/public_html/bin/luceneserver/;/usr/local/jdk1.6.0_26/bin/java -Xrs -jar ktlucene.jar"&

Same error

Trying to run
Code:
java -Xrs -jar ktlucene.jar&

Also fails as it can't find ktlucene.jar

Any help would be appreciated.

Thanks,
Wayne

Moderator's Comments:
Mod Comment Please use code tags <- click the link!

Last edited by zaxxon; 10-31-2011 at 09:21 AM.. Reason: code tags, see PM
# 2  
Old 10-31-2011
Did you try
Code:
cd /home/powvets/public_html/bin/luceneserver/; nohup /usr/local/jdk1.6.0_26/bin/java -Xrs -jar ktlucene.jar &

?

You could also put your cd and other commands into a script and start just the script with nohup and &.
# 3  
Old 10-31-2011
Hi, thanks for the answer. I couldn't write a script if I had to.

I tried that and I got a command prompt with

Code:
root@palladium [/]# nohup: appending output to "nohup.out"

Does that mean it worked? How do I check to see what is running in nohup.out? The cursor went to a line below the output without a prompt, had to hit enter to get prompt.

Thanks again,

Wayne
# 4  
Old 10-31-2011
Usually if you don't get an error in Unix/Linux it is supposed to have worked. You can test it though with echo $? which shows the return code of the last entered command. Anything else but 0 is usually an error. The Java program itself might write it's own log - no clue.
If this is a continously running process in the background, you should be able to use something like
Code:
ps -ef| grep -i ktlucene

to see it running. No clue if you can test it for output or how to interact in any way with that process.
That it writes this nohup.out is normal.

From the man page:
Quote:
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to `nohup.out' if possible,
`$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use `nohup COMMAND >
FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documen-
tation for details about the options it supports.
# 5  
Old 10-31-2011
Hi Zaxxon, that worked, code 0.

Thanks Heaps,
Wayne
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Output of ssh command from localhost - direct to local file.

Hi, i'm trying to gather details from remote hosts and want them to be written to my local linux machine from where i'm using SSH. My command looks some thing like this ssh -q remotehost 'bash -s' <command.txt where command.txt is a file in my local machine containing ps -ef |grep httpd |... (1 Reply)
Discussion started by: poga
1 Replies

2. Fedora

Clueless re Java: /opt vs. /usr/local

It seems this is a oft debated item, that's over my head. So here's what I've got: Java 7 set up at /opt/ but I really want it at /usr/local... What have I done? Have: Debian 7 (whezzy) with gnome, so what do I do to set things back where it should be? I guess this is a hot topic... (3 Replies)
Discussion started by: sas
3 Replies

3. Shell Programming and Scripting

Using a find command in ssh but using local variables?

I have a script like this (Yes, I know the DAY6 number isn't right - I'm just testing at this point): DAY0=`date -I` DAY1=`date -I -d "1 day ago"` DAY6=`date -I -d "2 days ago"` if then ssh root@synology1 nohup rm -rf "/volume1/Fileserver/$DAY6" fi I've tested the line to remove the... (5 Replies)
Discussion started by: Orionizer
5 Replies

4. Shell Programming and Scripting

Condition local or remote server command

Hello, Can you help me ? $7 fits to remote server. I can launch the script from local or remote server. I would like my_script.sh to choose local or remote command depending the variable $7. Is the function f1 right or wrong ? In this moment, i can't test it. Thanks in advance. I create... (3 Replies)
Discussion started by: amazigh42
3 Replies

5. Shell Programming and Scripting

Temporary command history on local machine

Hey guyz, I'm trying to get the command history for my active users sessions on the local machine and i kinda hit a tough wall Is command-line history for my current user saved somewhere else besides $HOME/.bash_history? I have been told that there is some temporary file stored on the local... (2 Replies)
Discussion started by: mishu_cgm
2 Replies

6. Shell Programming and Scripting

Executing local script/command on remote server

I have a command that I want to run on machine B from machine A. If I run the command on machine B locally, it works fine. Here is the command: for n in `find /data1/ -name 'ini*.ext'` ; do echo cp $n "`dirname $n `/` basename $n .ext`"; done From machine A, I issue this command ... (3 Replies)
Discussion started by: dirtyd0ggy
3 Replies

7. Red Hat

Command to find the local harddisks of a server ? Including their size

Hi guys How do I find the harddisks in a server ? Rgds Nishant (4 Replies)
Discussion started by: thevishy
4 Replies

8. UNIX for Advanced & Expert Users

Using SCP command in IBM AIX to download file from remote to local system

Hi, When i run the code in solaris unix machine, the file from remote server is getting downloaded. but when i use the same code in IBM AIX remote machine, it is not running. It is saying "Erro during scp transfer." Below is the code. Please give some resolution. SCPClient client = new... (1 Reply)
Discussion started by: gravi2020
1 Replies

9. HP-UX

How to execute a remote file with local command

Hello, I know this is somewhat strange, but please let me know if possible. I want to execute a program file in the remote machine with command on the local machine. Let me make things more clear. Suppose I have a cc on my local system and do not have that on the remote system. I want to use... (2 Replies)
Discussion started by: Veera_Raghav
2 Replies

10. Shell Programming and Scripting

running command remotely to populate local variable

If I run this # ssh remote-server 'du -sk /usr/platform/`uname -i`/' 174 /usr/platform/SUNW,Sun-Fire-V245 I get my output just fine, However, if i try to do the same but populate a local variable within my script called for example 'result' #!/bin/ksh result=`ssh remote-server... (3 Replies)
Discussion started by: hcclnoodles
3 Replies
Login or Register to Ask a Question