1

I have a python script that I would like to be used as a service in Suse Linux.

I tried creating a script.conf file in /etc/init.d that looks like this:

description "File service"
author  "Me"

start on runlevel [234]
stop on runlevel [0156]

chdir /app/file/bin
exec /app/file/bin/script.py
respawn

How do I test if this script is working ? I have no idea what command to type to start running this service. Any answers to this will be greatly appreciated thanks.

1
  • superuser.com may be a better place to ask this question. Commented Mar 8, 2017 at 6:42

1 Answer 1

0

Lets break answer in two parts first how to configure it and Second how to run and test it as process.

How to configure?

Configuration you have posted above is correct. But file is supposed to be created under directory /etc/init/myscript-service.conf (That's what I follow in my scenario). Another configuration part is you have to make script file executable so that it can run as service.

Linux command

chmod u+x /app/file/bin/script.py

You need to add below line in your python script.

#!/usr/bin/python

And install upstart tool.

After above all configuration you are ready to run script as service.

How to run and test?

Once you have created file myscript-service.conf you can start the service as normal service in linux using below command.

service myscript-service start

It will give you process id. And you can start/stop/status it like normal service.

Logs you can find under

/var/log/upstart/myscript-service.log

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.