Ask Your Question
1

How to automatically run a python program while OS boot-up in Fedora 24?

asked 2016-11-17 06:56:22 -0500

buvaneshkumar gravatar image

This is my Python code

I want to run this python program automatically while OS boot-up in Fedora 24. Anyone could you please help me.

edit retag flag offensive close merge delete

Comments

Which Desktop Environment are you running, if any?

ifohancroft gravatar imageifohancroft ( 2016-11-17 07:18:18 -0500 )edit

I'm using Gnome DE

buvaneshkumar gravatar imagebuvaneshkumar ( 2016-11-18 06:18:16 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-17 08:20:05 -0500

aeperezt gravatar image

You need to add it as a service, you best option is to create a systemd service for your program there you can you can set at what stage of booting it will run before or after what services. Read this https://access.redhat.com/documentati... you can learn how to create one service file for your script.

edit flag offensive delete link more

Comments

Hi aeperezt,

Thanks for your answer. As per you said, I wrote service file for my python script. My service script as below,

[Unit] Description=My script service After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/python /root/ter.py [Install] WantedBy=multi-user.target But while booting my system, the service is failed. I got some errors in log. The error is, Nov 18 12:10:23 server.example.com systemd[1]: Started My script service. Nov 18 12:10:23 server.example.com systemd[1]: Starting My script service... Nov 18 12:10:25 server.example.com python[2635]: Failed to parse argume

buvaneshkumar gravatar imagebuvaneshkumar ( 2016-11-18 06:22:39 -0500 )edit

I think you need to use fork so it run in background while other services are running, also you could use this ExecStart=/usr/bin/sh -c "/usr/bin/python /root/ter.py & " that way it run your script and set to run in background. try it and good luck

aeperezt gravatar imageaeperezt ( 2016-11-18 06:41:36 -0500 )edit

I tried as you said I replaced that ExecStart. But the same thing happening. I think it seems my script requires X based system. my script ran before x system start running while booting process.

buvaneshkumar gravatar imagebuvaneshkumar ( 2016-11-18 07:00:14 -0500 )edit

You script require X then you should set it to run after it runs or add i as an application after the user login. If you using gnome you should look at starting applications on gnome at start.

aeperezt gravatar imageaeperezt ( 2016-11-18 07:35:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-17 06:56:22 -0500

Seen: 243 times

Last updated: Nov 17 '16