Script should keep running only at specific time

I want a script to run once at 6:00AM, keep running, and then STOP running at 23:59PM.

Hi,
Can we use crontab and can you write one example where the script will run only in between 6am to 00 daily.

Yes?
What have you done so far?
Not knowing your environment, your platform, OS, and shell you use, all I can say is to look at the man pages of at command
and to give you more help, on top of the pre-cited we will also need to see what your script looks like, what it is doing as we not the slightest idea what it will be doing all that time...

Hi i have java script bulk.sh. inside this i have jar file where my java code is written.

That is not much of a help, we still have no idea what is going on...

My current .sh file below. Which need to run only once and it will do its job. I need below script to run only at 6am to 00.

#!/bin/bash

BM_HOME=/home/jsoc

BM_LIB=$BM_HOME/lib/BulkTerminationLib/
BM_PROPS=$BM_HOME/properties/
BM_LOG_PATH=$BM_HOME/logs
BM_PROPS_FILE=$BM_HOME/properties/bulktermination.properties
BM_log4j_FILE=$BM_HOME/properties/bulkterminationlog4j.properties

CLASSPATH=BulkTermination:$BM_LIB/BulkTermination.jar:$BM_LIB/log4j-1.2.15.jar:$BM_LIB/com.mysql.jdbc_5.1.5.jar:$BM_LIB/http-core-4.1.jar:$BM_LIB/httpclient-4.0.3.jar:$BM_LIB/org.apache.commons.httpclient.jar:$BM_LIB/org-apache-commons-logging.jar

echo $CLASSPATH

########################################################################################################################################

java  -cp $CLASSPATH -DTPP_PROPS=$BM_PROPS_FILE -DTPP_log4j=$BM_log4j_FILE com.sap.term.main.BulkTermination 1>>$BM_LOG_PATH/BulkTermination.log 2>>$BM_LOG_PATH/BulkTerminationError.log &

So what is it doing? during all that time?
It can more tricky than you think...
From what I understand, your program once executed runs forever ( normally ...) and you want it to stop at a given time
This can be achieved applying same rules as services or daemons: you are to write a start/stop init script, then once tested and perfectly functional use it in cron with start option at 6am and stop at 23:59
But what happens when it for any reason is no more running in the hours it should? ...

It will pick some data from database and update it. When it stops it will stop updating the database and when it runs again it should continue from the same.
Can you please help me by writing script.

From the code submitted you launch a Java application, what is there to end it cleanly since it is writing to 2 log files?

How do you achieve both?

Its my peak 00 to 6am why i dont want this to run coz some other things will be running in my server. So i want to stop this script to keep running on my peak time.
When i start the script it will keep on updating status to db, when i stopped it , it will stop processing updating status to db. But killing the process wont work as i tested these will give stuck data or failures.

Exactly what was expected, so in other words we cannot help you more with the information given, as we do not know how to stop the application gracefully, and as we don't know the OS we have no idea if it provides init script templates
If this application were part of a vendor's solution it sure has given you information on how to create a start/stop script if it was not delivered with, this is basic since what happens in case of server failure? or reboot, How will it start automatically without?

If there is a server failure or reboot. I have to run the script again as the process gets killed surely.

what about

?
There are procedures to restart after a crash or issue, how come you have nothing?
How do you stop your application?

We have procedure to stop we used to kill the process. For start we have to go bin path and have to start using ./start.sh.

--- Post updated at 04:52 PM ---

Stuck or failure data will be around 100. I can clear it later.

So what is in the start.sh?
How come they havent given you a stop.sh?
What else java is running on your server?
because if nothing else you can search for the PID of java stuff and kill it no?
Else you have to write code in start.sh to get the PID of the process in order to use it to kill the process with the stop option of your start/stop script

Start.sh is my application start script. Stop.sh we dont have. Nothing else running java process as of now except in start.sh java processes.