If I put an executable shellscript into /etc/rc.d/init.d, will it run at startup?
13 thoughts on “Stupid Fedora Question”
The scripts in /etc/init.d aren’t run unless they are linked to from one of the runlevel directories (e.g. /etc/rc.d/rc3.d). They are all passed a start/stop/reload/restart parameter that they should deal with and ideally should have a chkconfig line at the top of the script so that utility can figure out what to do with it.
The easiest way to hook in, would be to add your script to /etc/rc.d/rc.local. It runs after the rest of the init scripts run.
The easiest way to hook in, would be to add your script to /etc/rc.d/rc.local.
Thanks, that was the advice I was looking for. I had even known, but forgotten that from a previous search, but I couldn’t figure it out from the one I ran today.
They still make it too hard…
Someone should put together a Googlable page titled, “Fedora Startup Scripts.”
But that’s not just a Fedora thing, that’s standard AT&T System V Unix dating from the mid 80’s and used by almost everything that isn’t BSD.
Of course. That would be such an obvious source for Linux newbies…
As an engineer, you’ve no doubt kept and used reference books in your field. May I suggest purchasing one on Fedora?
If you’re not interesting in buying a book, there’s also the Linux Documentation Project. They have a number of guides: http://tldp.org/guides.html
I believe Red Hat, which is closely related to Fedora, also has fairly good documentation somewhere at their website.
When I was learning this a long time ago, I liked the Evi Nemeth book, which is nicknamed the “purple sysadmin book”, but that’s probably a lot more detail than you’d like to get into.
One thing we might ask is, what are you trying to do with your Fedora installation? That might help us gauge how deeply you want to go into getting things done or understanding what something does.
Yes, I have purchased books in the past, for Redhat, but I haven’t bought one for Fedora yet (partly because there’s a new core every year or so, and they become obsolete). Yes, I could have gone to dig into the docs at the Fedora site, but it was quicker and easier to just ask, since I have a pretty savvy readership. Thanks for the input.
You may also want to look at the manpage for ‘chkconfig’. It is used to manage the startup and shutdown scripts for most Linux systems like Red Hat and Fedora.
I’m aware of chkconfig, but this is a script I’m writing myself, and run by me as a user. The simplest thing is to just stick it in local.
To be fair, the whole UNIX init script scene is a mess, and the have been multiple attempts to fix it (inittab, anyone?) have ended up just ended up adding layers because you can’t get rid of the legacy stuff and then it all gets more complex…
I actually rather like the scheme in Solaris 10 merging the various init scheme, cron, and inetd into a single system.
Since this is a script that you want run as your own user ID rather than as root, you may want to consider avoiding the whole init script system, and just use cron. Just use “crontab -e” to edit your crontab file, and add an entry along the lines of “@reboot /home/rand/startup-stuff.sh”, which as you might imaging, will get run once at system startup time.
Well, I just figured that the first line in the script would be ‘su simberg’
The scripts in /etc/init.d aren’t run unless they are linked to from one of the runlevel directories (e.g. /etc/rc.d/rc3.d). They are all passed a start/stop/reload/restart parameter that they should deal with and ideally should have a chkconfig line at the top of the script so that utility can figure out what to do with it.
The easiest way to hook in, would be to add your script to /etc/rc.d/rc.local. It runs after the rest of the init scripts run.
The easiest way to hook in, would be to add your script to /etc/rc.d/rc.local.
Thanks, that was the advice I was looking for. I had even known, but forgotten that from a previous search, but I couldn’t figure it out from the one I ran today.
They still make it too hard…
Someone should put together a Googlable page titled, “Fedora Startup Scripts.”
But that’s not just a Fedora thing, that’s standard AT&T System V Unix dating from the mid 80’s and used by almost everything that isn’t BSD.
http://en.wikipedia.org/wiki/Init
The googlewords you want are “SysV init scripts.”
The googlewords you want are “SysV init scripts.”
Of course. That would be such an obvious source for Linux newbies…
As an engineer, you’ve no doubt kept and used reference books in your field. May I suggest purchasing one on Fedora?
If you’re not interesting in buying a book, there’s also the Linux Documentation Project. They have a number of guides: http://tldp.org/guides.html
I believe Red Hat, which is closely related to Fedora, also has fairly good documentation somewhere at their website.
When I was learning this a long time ago, I liked the Evi Nemeth book, which is nicknamed the “purple sysadmin book”, but that’s probably a lot more detail than you’d like to get into.
One thing we might ask is, what are you trying to do with your Fedora installation? That might help us gauge how deeply you want to go into getting things done or understanding what something does.
Yes, I have purchased books in the past, for Redhat, but I haven’t bought one for Fedora yet (partly because there’s a new core every year or so, and they become obsolete). Yes, I could have gone to dig into the docs at the Fedora site, but it was quicker and easier to just ask, since I have a pretty savvy readership. Thanks for the input.
You may also want to look at the manpage for ‘chkconfig’. It is used to manage the startup and shutdown scripts for most Linux systems like Red Hat and Fedora.
I’m aware of chkconfig, but this is a script I’m writing myself, and run by me as a user. The simplest thing is to just stick it in local.
To be fair, the whole UNIX init script scene is a mess, and the have been multiple attempts to fix it (inittab, anyone?) have ended up just ended up adding layers because you can’t get rid of the legacy stuff and then it all gets more complex…
I actually rather like the scheme in Solaris 10 merging the various init scheme, cron, and inetd into a single system.
Since this is a script that you want run as your own user ID rather than as root, you may want to consider avoiding the whole init script system, and just use cron. Just use “crontab -e” to edit your crontab file, and add an entry along the lines of “@reboot /home/rand/startup-stuff.sh”, which as you might imaging, will get run once at system startup time.
Well, I just figured that the first line in the script would be ‘su simberg’