Running a custom daemon on start up

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I've got a small project that's based around a raspberry pi. A central part of this project is for my program to be executed on start-up and run until shutdown, all while running stand-alone (that means no SSH). One way I've found is to run my program with nohup, but this still requires an ssh session to start.



I've written the program following the guidelines for creating a linux daemon, yet when I execute it as sudo ./myprogram, it doesn't actually seem to be running as root (it can't to write to the GPIO pins). What is the proper way of going about this?







share|improve this question















  • 1




    What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
    – Filipe Brandenburger
    May 4 at 5:52











  • Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
    – Astrum
    May 4 at 6:24






  • 1




    Please state the version you are using, "The latest one" is changing over time!
    – MatsK
    May 4 at 6:28














up vote
0
down vote

favorite












I've got a small project that's based around a raspberry pi. A central part of this project is for my program to be executed on start-up and run until shutdown, all while running stand-alone (that means no SSH). One way I've found is to run my program with nohup, but this still requires an ssh session to start.



I've written the program following the guidelines for creating a linux daemon, yet when I execute it as sudo ./myprogram, it doesn't actually seem to be running as root (it can't to write to the GPIO pins). What is the proper way of going about this?







share|improve this question















  • 1




    What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
    – Filipe Brandenburger
    May 4 at 5:52











  • Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
    – Astrum
    May 4 at 6:24






  • 1




    Please state the version you are using, "The latest one" is changing over time!
    – MatsK
    May 4 at 6:28












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've got a small project that's based around a raspberry pi. A central part of this project is for my program to be executed on start-up and run until shutdown, all while running stand-alone (that means no SSH). One way I've found is to run my program with nohup, but this still requires an ssh session to start.



I've written the program following the guidelines for creating a linux daemon, yet when I execute it as sudo ./myprogram, it doesn't actually seem to be running as root (it can't to write to the GPIO pins). What is the proper way of going about this?







share|improve this question











I've got a small project that's based around a raspberry pi. A central part of this project is for my program to be executed on start-up and run until shutdown, all while running stand-alone (that means no SSH). One way I've found is to run my program with nohup, but this still requires an ssh session to start.



I've written the program following the guidelines for creating a linux daemon, yet when I execute it as sudo ./myprogram, it doesn't actually seem to be running as root (it can't to write to the GPIO pins). What is the proper way of going about this?









share|improve this question










share|improve this question




share|improve this question









asked May 4 at 2:56









Astrum

176126




176126







  • 1




    What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
    – Filipe Brandenburger
    May 4 at 5:52











  • Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
    – Astrum
    May 4 at 6:24






  • 1




    Please state the version you are using, "The latest one" is changing over time!
    – MatsK
    May 4 at 6:28












  • 1




    What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
    – Filipe Brandenburger
    May 4 at 5:52











  • Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
    – Astrum
    May 4 at 6:24






  • 1




    Please state the version you are using, "The latest one" is changing over time!
    – MatsK
    May 4 at 6:28







1




1




What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
– Filipe Brandenburger
May 4 at 5:52





What Linux distribution are you running on your Raspberry Pi? (Raspbian?) That information might be helpful in figuring out what to do... Your system should have a set of init scripts that run during boot (for instance, look for an /etc/init.d directory.) That's usually the proper place to configure scripts to launch daemons on start up.
– Filipe Brandenburger
May 4 at 5:52













Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
– Astrum
May 4 at 6:24




Yes, it's the latest version of raspbian. I took a look at that directory but am not sure how to make my own. Is it enough to just do DAEMON=/usr/bin/myDaemon and place my daemon executable in /usr/bin/?
– Astrum
May 4 at 6:24




1




1




Please state the version you are using, "The latest one" is changing over time!
– MatsK
May 4 at 6:28




Please state the version you are using, "The latest one" is changing over time!
– MatsK
May 4 at 6:28










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You can use systemd services to get this job done. It's easier to control your application via systemd have a look at this tutorial https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files






share|improve this answer





















  • Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
    – thecarpy
    May 4 at 11:12










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441693%2frunning-a-custom-daemon-on-start-up%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You can use systemd services to get this job done. It's easier to control your application via systemd have a look at this tutorial https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files






share|improve this answer





















  • Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
    – thecarpy
    May 4 at 11:12














up vote
0
down vote













You can use systemd services to get this job done. It's easier to control your application via systemd have a look at this tutorial https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files






share|improve this answer





















  • Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
    – thecarpy
    May 4 at 11:12












up vote
0
down vote










up vote
0
down vote









You can use systemd services to get this job done. It's easier to control your application via systemd have a look at this tutorial https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files






share|improve this answer













You can use systemd services to get this job done. It's easier to control your application via systemd have a look at this tutorial https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files







share|improve this answer













share|improve this answer



share|improve this answer











answered May 4 at 10:06









user7345878

1




1











  • Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
    – thecarpy
    May 4 at 11:12
















  • Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
    – thecarpy
    May 4 at 11:12















Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
– thecarpy
May 4 at 11:12




Welcome to unix stackexchange and thanks for your reply. While providing sources is always good, it would really help if you could provide an example, links can break.
– thecarpy
May 4 at 11:12












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441693%2frunning-a-custom-daemon-on-start-up%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)