LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How can I run a command automatically at startup? (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-run-a-command-automatically-at-startup-222413/)

luwigie 08-25-2004 06:11 PM

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!

Peacedog 08-25-2004 07:05 PM

this may answer your ?

http://www.redhat.com/docs/manuals/l...-services.html

hope that helps.
good luck.

luwigie 08-25-2004 10:35 PM

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?

realjustin 08-25-2004 11:52 PM

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.

myriad-zero 08-26-2004 02:21 AM

Exactly that is the place to put in. Make sure that you don't screw up anything else.

luwigie 08-26-2004 06:35 AM

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?

luwigie 08-26-2004 05:11 PM

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:

Sinope 08-26-2004 05:26 PM

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

rob.rice 08-26-2004 09:05 PM

Quote:

Originally posted by luwigie
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?

yes it runs as root and you will have to be root to kill it

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.