LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2008, 12:22 AM   #1
Anauj0101
LQ Newbie
 
Registered: Mar 2002
Posts: 26

Rep: Reputation: 15
Trying to run commands at boot Centos 5


I am running Centos 5 and am moving from an all windows server running open source software, to running Centos 5 with all of my software. My problem is i need to run some commands at boot, such as starting hamachi and starting a vnc user. I did try to use rc scripts, and i did get it to work.....kinda. When i boot it says bad command line interpreter. Is this an easier way to do this? RC scripts do seem to be more "getting into the guts of things", so if i could do it that way that would be great. Thank you.
 
Old 02-18-2008, 12:25 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
How about /etc/rc.local?

This, as the file will tell you, will execute commands after the normal rc.? startup services
 
Old 02-18-2008, 12:26 AM   #3
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
The simple hack is to make a script, put all the commandline stuff in there which works when you type it into the console, make it executable, and add the path to the script to the bottom of /etc/rc.local

It will run at login.

IIRC: CentOS also has a GUI for running programs at startup.
 
Old 02-18-2008, 04:15 AM   #4
Anauj0101
LQ Newbie
 
Registered: Mar 2002
Posts: 26

Original Poster
Rep: Reputation: 15
Ok that works great, except for 1 thing i need to run them as root. what would be the proper way of using su in this case.
 
Old 02-18-2008, 04:41 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I would have thought startups were as root, but you may need to test (try something like "touch /home/test.file") and when booted, do "ls -l /home" and see who the owner is.

If not, a potential dodge is to run from root's crontab with

@reboot command

Last edited by billymayday; 02-18-2008 at 06:28 AM.
 
Old 02-18-2008, 06:17 AM   #6
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
AFAIK: startups run suid root.
Have you tried?
 
Old 02-19-2008, 02:49 AM   #7
Anauj0101
LQ Newbie
 
Registered: Mar 2002
Posts: 26

Original Poster
Rep: Reputation: 15
Well i did find that the test file was created by root. So something else is wrong. What i am trying to do is run a tightVNC user and start hamachi. The vnc user starts but the display is all messed up, and hamachi gives me an error saying that a setup file is missing. But if i run all of these same exact commands after login as root everything works great. That my problem in a nutshell
 
Old 02-19-2008, 02:54 AM   #8
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I don't know either program, but it may help if you post the exact commands.

Note that there's a pretty good chance that environment variables aren't set in rc.local, so you may need to provide the full path for the command, specify where config files are, etc.
 
Old 02-19-2008, 03:04 AM   #9
Anauj0101
LQ Newbie
 
Registered: Mar 2002
Posts: 26

Original Poster
Rep: Reputation: 15
vncserver :64 -geometry 1024x768 -depth 16 -name anauj

/sbin/tuncfg
hamachi start
hamachi go-online

Now i found something wierd the vnc server works fine if i type it in manually but if i run the same exact command from a script the display is messed up.

Hamachi requires one time initialization (per Linux user account).
This step generates cryptographic key pair and creates ~/.hamachi
directory where Hamachi stores the keys, the configuration and the
state. To perform this initialization run

./hamachi-init

This is what hamachi can not find when i run it from the rc.local. I have run this command, as i said earlier the hamachi commands do work if i run them after login as root. Hope that helps you. Also btw greatful for all the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run commands on each boot linux-rulz Ubuntu 8 12-27-2011 05:28 PM
run centos on ramdrive mattsoftnet Linux - Server 1 09-13-2007 04:42 PM
k3b doesn't run on Centos 5 x86_64 dralexpe Linux - Software 7 08-05-2007 12:37 PM
CentOS-run as root phantom_cyph Linux - Distributions 3 03-26-2007 06:19 PM
rpm and yum commands failing on CentOS 4.2 amussaw Linux - Newbie 1 03-21-2006 11:06 AM


All times are GMT -5. The time now is 08:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration