LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-21-2010, 12:40 AM   #1
kapila_sr
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
Add new service on rhel 5


Dear All,

I'm using java socket server program for transaction routing on rhel5. So I make a jar file of server to be run.

Now I need to add my application as a service. I just search in google how to do that, And i found some way and it is bellow,


#!/bin/bash
#
# chkconfig: 2345 85 15
# description: epic tle
# processname: epictle
# source function library
. /etc/init.d/functions


export JAVA_HOME=/opt/EpicTle/java1.6
export PATH=$JAVA_HOME/bin:$PATH

RETVAL=0

start() {
echo -n $"Starting epictle services: "
sh /root/les/run/lnrunr.sh
RETVAL=$?
echo
}

stop() {
echo -n $"Shutting down epictle services: "
java -jar /opt/EpicTle/config/tlecommands.jar 2
RETVAL=$?
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
status)
status epictle
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL





this is the script in (/etc/init.d/)


its start and stop working correctly (but I cant see green 'OK' while its starting)

But any time it is showing the massage "epictle is stopped" when I check the status even it is running .

Please can you tell me what is the wrong with me ?

or else another way


02)

Next issue I'm facing

I have written simple script (sh) to run jar file and I'm using bellow code for putting it as background

sh /opt/EpicTle/tle/run.sh >/root/.epicline/logs/debug/console.out 2>&1 &

I want to change 'console.out' file per day with date name rather than going with one file

Best regards
-Kapila
 
Old 07-21-2010, 12:47 AM   #2
jcalzare
Member
 
Registered: Aug 2009
Location: Chicago
Distribution: CentOS
Posts: 114

Rep: Reputation: 34
I'm not sure for #1, but for #2 you should use logrotate. You can use it to rotate that log file based on your parameters (size, time, etc). You can also use it to prepend a date too for organization (20100721.console.out). Logrotate can also be used to retain the logs for a certain period of time and flush any older than a certain time limit.
 
Old 07-21-2010, 12:54 AM   #3
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS, Manjaro
Posts: 179

Rep: Reputation: 27
Hi,

You need to use the killproc <your_prog_name> to get [OK|FAILED|...] message.

or else read /etc/init.d/functions script.

You need to use the function echo_success,echo_<....> from /etc/init.d/functions file, but this dependents upon your on finding of the PID status and call the appropriate function.
 
Old 07-21-2010, 01:00 AM   #4
kapila_sr
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks

Can you send script for getting like "20100721.console.out"?
Sorry Im not too familiar with linux

Regards
-Kapila
 
Old 07-21-2010, 08:20 AM   #5
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Rep: Reputation: 15
Here you go,

create a script as below:

Code:
Today=`date +%Y%m%d`
sh /opt/EpicTle/tle/run.sh >/root/.epicline/logs/debug/$Today.console.out 2>&1 &
and use this one
 
Old 07-22-2010, 04:13 AM   #6
kapila_sr
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks but still issue with me

Im meaning it will create the log file with date name when i start server . But on next day, I can see new file in folder still logging data to previous day log file. to create new file, i need to restart server

Regards
-Kapila
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Poppassd service error ( RHEL 4) navinchotia Linux - Newbie 1 08-04-2009 06:35 PM
Setting up a service account in RHEL 5 kenneho Linux - Server 1 06-23-2009 09:54 AM
how to add a service at startup vijaya_svk Linux - Software 5 07-15-2008 07:42 AM
How do I start the web service on RHEL 5? JeffS-at-Areva Linux - Newbie 1 05-20-2008 12:43 PM
how to add service in service list akamol Linux - Software 2 07-20-2006 01:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration