[CentOS] Creating a user defined service in Cent os

Hakan Koseoglu hakan at koseoglu.org
Mon May 24 14:26:22 UTC 2010


Hai Chaitanya,

On 24 May 2010 14:59, Chaitanya Yanamadala <dr.virus.india at gmail.com> wrote:
> hai
>  i have a perl script which will automatically check for the existing files
> and then ftp them to a server, this one runs in a loop until i kill it, now
> what i wants is i want to make this as a service so that it can keep on
> running until i kill the service. so does any one have an idea how to do
> this??

Create an init script with start and stop options, spawn your perl
script as a background process and store the PID of this into a
pidfile in /var/run. At the stop section kill the pid stored in the
pidfile. You should be able to find some similar scripts in
/etc/init.d. Then add it to the services and you're done. You should
be able to issue the stop & start commands just like any service.

-- 
Hakan (m1fcj) - http://www.hititgunesi.org



More information about the CentOS mailing list