[CentOS] making a script into a service

Mon Dec 9 13:40:22 UTC 2013
Liam O'Toole <liam.p.otoole at gmail.com>

On 2013-12-09, Larry Martell <larry.martell at gmail.com> wrote:
> On Mon, Dec 9, 2013 at 8:00 AM, Fabrizio Di Carlo
><dicarlo.fabrizio at gmail.com> wrote:
>> Try to use this
>> http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ it
>> allows you start/stop/restart the script using the following commands.
>>
>> python myscript.py start
>> python myscript.py stop
>> python myscript.py restart
>>
>>
>> Source:
>> http://stackoverflow.com/questions/16420092/how-to-make-python-script-run-as-service
>
>
> Yes, I've seen that question and site. I want to be able to control it
> with the service command. The technique on this site makes the script
> a daemon, but that does not make it controllable with service.
>
>

Assuming the first line of your script is

	#!/usr/bin/env python

and the script is executable, then you can invoke it like this:

	myscript start
	myscript stop
	myscript restart

If you then place the script in /etc/init.d/, you have yourself a
service. See the 'service' man page.

-- 

Liam