Chaitanya Yanamadala
2010-May-24 13:59 UTC
[CentOS] Creating a user defined service in Cent os
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?? Chaitanya -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20100524/82d77d26/attachment.html>
On Mon, May 24, 2010 at 9:59 AM, 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?? > > ChaitanyaYou can write a start/stop script and put in in /etc/init.d, or you can convert it to run from cron and put it in the user's crontab (instead of using an infinite loop and sleeping in the script, remove the loop & sleep and have cron run the script however often you need to check for files). Cron would be the preferred way here.
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
Jerry McAllister
2010-May-24 14:33 UTC
[CentOS] Creating a user defined service in Cent os
On Mon, May 24, 2010 at 07:29:21PM +0530, Chaitanya Yanamadala 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??Has anyone syggested using rsync instead of a Perl script? That is designed just for things like this and works well and might be more secure than the Perl script. Or you could put use rsync in your Perl script. You will need to create a little binary to invoke the Perl script. Then create an rd.d type script that takes a 'start' and 'stop' put it in and run it with a 'start' parameter. Give the startup script a 'stop' when you want to quite. Look at the stuff in init.d, etc such as apachectl for hints. You probably don't need anything as elaborate as that for the start/stop script, but it is a good example. ////jerry> > Chaitanya> _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos