LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Services in Linux using .sh file (https://www.linuxquestions.org/questions/linux-newbie-8/services-in-linux-using-sh-file-4175488512/)

ashok.565656 12-19-2013 12:44 AM

Services in Linux using .sh file
 
Hi Everyone,

I created a run.sh file to run executable jar in Linux.it will working fine.Now i need to this run.sh file run as services.So i created a script as follows,

Code:

#!/bin/sh
. /etc/rc.status
rc_reset
case "$1" in
    start)
        echo -n "Trigger the Report"
        startproc /usr/Trigger/run.sh
       
 
        rc_status -v
        ;;
esac
rc_exit

and I named it as rc.TcStart.Then i run in terminal as,

Code:

service rc.TcStart start
then i got the below error.

Code:

service rc.TcStart start
Trigger the reportstartproc:  cannot execute /usr/Trigger/run.sh: Exec format error

Please tell anyone how to solve this or how can i create service for jar file.

Thanks,

Ashok

pan64 12-19-2013 12:52 AM

I think startproc can only execute binaries, shell scripts cannot be started.

ashok.565656 12-19-2013 12:54 AM

Then how can i run sh file as service.please tell me how to do it.

Thanks,
Ashok

pan64 12-19-2013 12:59 AM

you can convert any shell script to binary. It is called shc.
http://www.thegeekstuff.com/2012/05/...-shell-script/

jpollard 12-19-2013 10:24 AM

I think the shell script just needs to be marked executable.


All times are GMT -5. The time now is 09:37 PM.