Deja Q
(1000+ posts)
Send PM |
Profile |
Ignore
|
Fri Sep-22-06 09:37 PM
Original message |
|
Boot-up batch file. I need to automatically run a command with root permissions so I don't have to manually type it in each boot.
How can I do this?
Thx!
|
trotsky
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sat Sep-23-06 10:01 AM
Response to Original message |
|
Can you put a script file in /etc/rc.d or the equivalent for your OS?
|
Deja Q
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sat Sep-23-06 01:03 PM
Response to Reply #1 |
|
Edited on Sat Sep-23-06 01:03 PM by HypnoToad
Thanks for the tip! I do have some experience with editing config files; I just find it easy to forget which ones at times. :dunce: One day I'll have everything memorized... by then I'll have wanted to have studied ActiveDirectory or something... :D
|
Tandalayo_Scheisskopf
(1000+ posts)
Send PM |
Profile |
Ignore
|
Mon Sep-25-06 11:41 PM
Response to Reply #3 |
bemildred
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sat Sep-23-06 12:12 PM
Response to Original message |
| 2. The previous fellow is correct. |
|
You would use a shell script that is run by init at startup, usually kept in /etc/rc or /etc/rc.d or similarly named directories, perhaps called by a startup script in /etc. Unfortunately, in my experience, the arrangement of this functionality is one of the things that people like to fiddle with, so some assembly may be required to identify exactly how one ought to do it on your system.
You could try "man boot" or "man init" to start getting some clues.
|
longship
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sat Nov-11-06 01:19 PM
Response to Reply #2 |
| 5. The standard location for scripts is /etc/init.d |
|
Depending on your particular distribution (Red Hat, Ubuntu, Gentoo, etc.) there is a utility to update which boot scripts run at boot time. This is typically accomplished by updating links in /etc/rc.d
Your distribution should have specific instructions on how to do this.
|
MazeRat7
(1000+ posts)
Send PM |
Profile |
Ignore
|
Wed Dec-27-06 09:30 PM
Response to Original message |
| 6. Typically you put a post boot call to the cmd file in /etc/rc.d/init.d/rc.local |
|
Be sure to background it if you don't want to wait for completion or its a non-terminating deamon.
MZr7
|
Recursion
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sat Jan-06-07 11:08 PM
Response to Original message |
| 7. In principle you don't want to touch /etc/init.d |
|
Though that depends on your distro. If you just want command foo to run at boot-time, put
foo &
in /etc/rc.d/rc.local
The location of rc.local may vary; to find it for sure run
find /etc -name 'rc.local'
|
meldroc
(1000+ posts)
Send PM |
Profile |
Ignore
|
Wed Jan-10-07 05:25 PM
Response to Reply #7 |
| 8. rc.local is where you want to tinker. |
|
Edited on Wed Jan-10-07 05:28 PM by meldroc
On Ubuntu systems, the file is /etc/rc.local, your location will vary, depending on your Linux distro.
/etc/init.d is where scripts are put to start up regular software, such as MySQL, all sorts of daemons, etc. It's built in a very specific way so sysv style init software knows how to deal with it. If you tinker in this directory, make sure you know exactly how things work in here, or you can break all sorts of stuff. Also, you may find that if you download updates to your distro, they may blow away any changes you make in this directory.
But rc.local is intended for user customizations, so you can put your boot-time commands here without too much hassle.
|
Recursion
(1000+ posts)
Send PM |
Profile |
Ignore
|
Sun Feb-25-07 02:09 PM
Response to Reply #8 |
| 9. I think FHS specifies /etc/rc.d/rc.local |
|
and most distros that don't put it there satisfy that requirements with a symlink.
The important thing is not so much remembering that file X is in location Y but having a general idea of what a given file is expected to do (eg, rc.local is where local programs not administered by your distribution can be run on init).
|
qnr
(1000+ posts)
Send PM |
Profile |
Ignore
|
Fri Mar-02-07 04:33 PM
Response to Original message |
|
Some distros will have an /etc/sysconf/bootmisc where you can enter commands to be run when you boot.
Also if you'd prefer to stay out of the actual init files, some versions of cron allow you to run commands at boot. Do a man 5 crontab and see if you have a time descriptor like @reboot
|
DU
AdBot (1000+ posts) |
Sun Oct 26th 2025, 04:23 AM
Response to Original message |