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
On Mon, May 24, 2010 at 9:59 AM, Chaitanya Yanamadala dr.virus.india@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??
Chaitanya
You 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@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.
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@centos.org http://lists.centos.org/mailman/listinfo/centos
hai all thank you for your replies. but can you send me some examples so that i can understand the things more better.. i am quite new to linux..
so can u help me out.
Chaitanya
On Mon, May 24, 2010 at 8:03 PM, Jerry McAllister jerrymc@msu.edu wrote:
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@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Chaitanya Yanamadala wrote:
hai all thank you for your replies. but can you send me some examples so that i can understand the things more better..
Hi
Have a look in the scripts in /etc/init.d/, some of them can be little bit complex, but worth the time to learn. You can start with /etc/init.d/atd.
Regards
mg.
thank u marcelo. so after creating a file how do i add it to service list. coz when i create a new file in /etc/init.d it is not appearing in the services list..
Chaitanya
"A man can get discouraged many times but he is not a failure until he stops trying..."
"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
On Mon, May 24, 2010 at 8:32 PM, Marcelo M. Garcia < marcelo.maia.garcia@googlemail.com> wrote:
Chaitanya Yanamadala wrote:
hai all thank you for your replies. but can you send me some examples so that i can understand the things more better..
Hi
Have a look in the scripts in /etc/init.d/, some of them can be little bit complex, but worth the time to learn. You can start with /etc/init.d/atd.
Regards
mg.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On May 24, 2010, at 11:06 AM, Chaitanya Yanamadala wrote:
so after creating a file how do i add it to service list. coz when i create a new file in /etc/init.d it is not appearing in the services list..
man chkconfig
-steve
-- If this were played upon a stage now, I could condemn it as an improbable fiction. - Fabian, Twelfth Night, III,v http://five.sentenc.es
Chaitanya Yanamadala wrote:
so after creating a file how do i add it to service list. coz when i create a new file in /etc/init.d it is not appearing in the services list..
Chaitanya
Hi
Then you use "chkconfig" to manage when the service will start, something like "chkconfig --add <service>", or simply "chkconfig <service> on", I'm not sure the best to way to do this.
There is a proper way of making the header for chkconfig, if I remember right. I think the man page give you this information.
mg.