Run command as root at Linux startup
Solved
poiuytrez
Posted messages
42
Status
Member
-
rdan -
rdan -
Hello, I am on Fedora Core 4, I would like to run a command or a script at system startup on Linux that requires root permissions. How should I do it?
Thank you for your help.
Thank you for your help.
7 answers
-
Hi, It seems the file /etc/init.d/rc.local is present on FC4 you just have to type as root
echo "yum -y upgrade" >> /etc/init.d/rc.local
on reboot the command will be executed However I agree with crabs. This is not a good idea to run an upgrade this way. Besides, doing an upgrade just to be able to brag that I have the latest version of the software is childish. -- lami20j -
Hi,
I don’t have FC4, but I have some old RH memories.
You need root rights.
Everything happens in the /etc/init.d directory and the rc(x).d (x) corresponding to the machine’s run level
watch how the folders are built with 'ls -il'.
For info everything starts from /etc/inittab...
In the rc.d:
a script that starts with K -> stop the service: run the script with the stop parameter
a script that starts with S -> start the service: run the script with the start parameter
Then 2 digits that allow sorting in ascending order and thus obtain the order
of starting the stop scripts for the service, then those of starting
Cheers, crabs
--
..., I think Slackware sounds better than 'Microsoft,'
-- Patrick Volkerding - founder and maintainer of Slackware -
Hello, if a single script is present in all rc*.d folders, it means it is started during the loading of modes 1 to 5 normally, so it would be launched 5 times if mode 5 is loaded, yet that's probably not the case, where is the error?
-
Thank you but I don’t want to launch a service at startup; I actually just want to run the command, as root:
#yum -y upgrade
Thank you! -
Hello,
In my statement, service was used in the broad sense.
It can be a script that launches a program...
Personally, at each startup, I run a command that synchronizes my clock with an NTP server, it's just a command put in a script.
Take the trouble to at least look in these startup areas.
Otherwise isn't it a bit dangerous to launch an OS update without the possibility to take control? Do some updates not require restarting certain services or even a machine reboot?
--
..., I think Slackware sounds better than 'Microsoft,'
-- Patrick Volkerding - founder and maintainer of Slackware -
Okay well I’m going to use this technique... In fact I knew it but I thought there was a cleaner method.
Thanks @+ -