Can not run reboot script when program started thru rc.local
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can not run reboot script when program started thru rc.local
I am running Fedora 14 and starting a c program from rc.local My program can request a system reboot from a script called rebootscript.sh that has been copied to the current working directory, also to the root/bin directory as well as to a user/bin directory. (I'm desperate... what can I say)
If I manually start the c program after the system boots up, it works fine. If I start the c program from rc.local it does not work. The only difference I see is that when starting from rc.local, root is the owner. When starting manually after boot, the user is the owner of the process.
I am no expert on this, but when the program runs from rc.local it is run as root, as you already pointed out. That makes the call with sudo unnecessary and may be this interferes somehow with the execution of the program. What happens if you start it manually from the command-line as root? Also, what happens if you start it from rc.local as a normal user?
I am running Fedora 14 and starting a c program from rc.local My program can request a system reboot from a script called rebootscript.sh that has been copied to the current working directory, also to the root/bin directory as well as to a user/bin directory. (I'm desperate... what can I say)
TobiSGD
Thanks for your response. I originally call the script without the 'sudo' and also without the '/bin/sh' (just the 'rebootscript'). None of these worked when the C program was started from the rc.local file.
I will try starting it from the command line as root.
How would I start the C program in the rc.local file with a different owner than root?
How would I start the C program in the rc.local file with a different owner than root?
su <user name> <path to compiled and linked C program>
or, if you want to run the different user's logon shell's logon initialisation: su - <user name> <path to compiled and linked C program>
Thanks to all.
I tried the su <user name> <path to compiled and linked C program>, without success. The /var/log/boot.log and messages files kept identifing the rc.local had a compatability problem. Never could get around that.
I have found an easier way to reboot my system from a c program. I just use system("init 6") in the c program and it works every time whether the c program was started with the rc.local file or manually after booting and login in.
Again thanks for the suggestions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.