2

I have a python script and that I have to run as a service/background process, I have tried python-daemon but it gives me errors is there any good way to run it as a service so that the script can be run in the background to accept messages and process files?

4
  • Can you provide the errors you are receiving? Commented Jan 30, 2018 at 4:12
  • os.umask(022) # Don't allow others to write Commented Jan 30, 2018 at 4:16
  • This is what i have tried "pypi.python.org/pypi/python-daemon" Commented Jan 30, 2018 at 4:17
  • Again please provide a code example that you have tried and the errors you are receiving? Commented Jan 30, 2018 at 7:22

1 Answer 1

1

I have made a sytemctl service file in /lib/systemed/system The file content is

[Unit]
Description=RPC SERVER
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/
Type=simple
ExecStart=/usr/bin/ python3 /home/ubuntu/rpc.py


[Install]
WantedBy=multi-user.target

/home/ubuntu/rpc.py is my python script path and i saved the file as rpcservertest.service so i can start the service using sudo systemctl start rpcservertest.service to stop sudo systemctl stop rpcservertest.service and to get status sudo systemctl status rpcservertest.service

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.