How can I run a command automatically at startup?
I want to start up my bandwidth monitoring programs (ntop and vnstat) on startup. I am running a server with FC2 in init mode 3 because the machine is old and I don't want to slow it down by running a GUI. Is there a way that I can do this? If so, do I just enter in the commands in a file like I would on the command line? Where does the output go? What user would run it?
Thanks! |
this may answer your ?
http://www.redhat.com/docs/manuals/l...-services.html hope that helps. good luck. |
Thanks for the reply, but that's not quite what I was looking for. I think that there is a file that gets run once everything else is loaded where you can put custom commands. Am I correct, any one?
|
It is called rc.local
It could be in various places, I'm not sure where in FC2. Probably /etc/rc.d/rc.local or someplace similar. Beware it gets run as root. |
Exactly that is the place to put in. Make sure that you don't screw up anything else.
|
A couple of questions:
So the user that it runs as is root? Where does the output go? No where? Do I just put in the commands on a line the same way I would at a command line, or do I have to seperate the commands more than just putting them on a seperate line? For instance would: vnstat -u -i eth0 ntop be sufficient to run two commands? |
Or would I have to put someting in between the programs?
Also, can I just do "ntop" for example rather than ./usr/bin/ntop?:confused: |
A newline is sufficient between the commands. Even a semicolon is enough, I think.
You may as well put /usr/bin/whatever rather than just whatever. I'm fairly certain $PATH is set before this point but it certainly cant hurt to give the full path. --S |
Quote:
the out put gose where you tell it to go or there may be a default log file it would be best if you were to read the man pages for the commands you want to log there may also be other settings for a command to run noninteractively or you may want to run them as an at job |
All times are GMT -5. The time now is 07:10 PM. |