LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2016, 09:32 AM   #1
Falco2016
LQ Newbie
 
Registered: Jan 2016
Posts: 4

Rep: Reputation: Disabled
Perl script would not start as a service


Can someone help me to figure out how to make the below Perl script to start as a service in Centos 7? I inherited this script and Iím not a Perl programmer, the more detailed help the better. I made it an executable but it fails to execute:
ďFailed to start SYSV: NAME Description process. (code=exited, status=1/FAILURE)Ē

#!/bin/bash
#
# NAME Startup script for the NAME Description
#
# chkconfig: 35 20 80
# Description: NAME Description process
# process: NAME
#

# source function library
. /etc/rc.d/init.d/functions

export PATH="$PATH:/usr/local/sbin"

RETVAL=0
prog="NAME"

start()
{
echo -n $"Starting $prog: "
daemon $prog
RETVAL=$?
echo
}

stop()
{
echo -n $"Stopping $prog: "
killproc $prog -KILL
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
 
Old 01-06-2016, 10:27 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,039

Rep: Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892Reputation: 2892
Welcome to LinuxQuestions.

What you posted looks like a generic SysV init script template. So what information haven't you told us yet? A service or daemon would not use capital letters nor probably be called NAME.
 
Old 01-06-2016, 11:18 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,719

Rep: Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034
ditto to the above and just to reiterate, there is zero perl in what you have shown us.
 
Old 01-07-2016, 06:11 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,843

Rep: Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472
The path to the daemon to be started is supposed to replace the NAME in the bash script (specifically the prog="NAME" line).

I suspect you are new to Linux as well as new to administration...

This script is legacy on CentOS 7 - and is being replaced by various systemd startup methods. It SHOULD still work, but some things will be harder to debug. It is easier to use the rc.local file to start site specific services.

Though it is possible to use a perl script as a daemon, it isn't recommended from a security point of view.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] question concerning postfix, a perl script, and Amazon Simple Email Service sneakyimp Linux - Server 8 11-12-2012 05:20 PM
How to run perl script as service tdnnash25 Linux - Server 6 12-24-2009 01:35 AM
Making a script start with service? your_shadow03 Linux - Newbie 13 12-05-2009 04:49 AM
Set a Perl script as an unix service (start with system) onlymed Linux - Newbie 2 04-01-2009 02:59 PM
write a script to start a service..how?? yenonn Linux - Newbie 6 05-26-2003 05:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:47 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration