Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding a command to run at boot time in RedHat 5

Posted on 2011-02-11
19
Medium Priority
?
1,149 Views
Last Modified: 2013-12-06
Hello,

I am trying to get a command to run at boot up on my RedHat 5 linux machine.  The command is
synergyc 111.111.111.111 &

Open in new window

I have added the command to my /etc/rc.d/rc.local file, but it still does not run.  I was wondering how i can get it to run.  Thank you.
0
Comment
Question by:Alex Matzinger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +6
19 Comments
 
LVL 9

Expert Comment

by:AriMc
ID: 34875764
The first thing to check is the file permissions as sometimes text editors remove the execute right from files when saving. So do a "ls -al /etc/rc.d/rc.local" and make sure there it looks like:

-rwxr-xr-x 1 root root 306 2009-03-08 20:35 rc.local

The 4th character "x" is the most important one.

0
 
LVL 4

Expert Comment

by:HawyLem
ID: 34875769
Try to make it as a script and add it to the rc.local file

http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/
0
 
LVL 23

Expert Comment

by:savone
ID: 34875772
It should run at boot if it is in the rc.local file, you may not be getting the results you want because the network is coming up AFTER the command runs.  I am familiar with synergy. ;)

Try putting it in the startup programs in gnome.  It will start when you log in as the user and the network will be up already.

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 23

Expert Comment

by:savone
ID: 34875780
Also another work around would be to put a sleep in front of it.

sleep 5; synergyc 111.111.111.111 &

Although this will slow down your boot up by 5 seconds. :)
0
 
LVL 4

Author Comment

by:Alex Matzinger
ID: 34875938
@AriMc
I have made sure that the file is execuatble.

@HawyLem
I have tried the methods on that link as well.  Red Hat doesn't support 'update-rc.d' ( i also tried some of the methods in the comments of that page and couldn't get it to work)

@savone
I tried the sleep command and still nothing.  I think you are right about the network not being up when the command is being run.  I think i may just have to deal with logging in before the command starts.
0
 
LVL 23

Expert Comment

by:savone
ID: 34876077
That's what happened to me, so I added it in the gnome startup apps and it worked great.
0
 
LVL 6

Expert Comment

by:de2Zotjes
ID: 34878023
rc.local is the very last bit of code that is run as part of the boot process. On an old-fashioned setup the network is up by that time. Newer installations that depend on network manager for the network connectivity will not provide connectivity until a user (who configured a network connection) logs in.

Depending on the role the machine fulfills you might want to promote your personal network configuration settings to system settings. Doing that and changing the setting [ifupdown] managed=false to managed=true should get you earlier connectivity.

You can even -if the box is a desktop- just use system-config-network to setup the connectivity
0
 
LVL 3

Expert Comment

by:oppofwar
ID: 34886176
Open /etc/rc.sysinit and enter the command on the last line , it will run before network starts
0
 
LVL 3

Expert Comment

by:oppofwar
ID: 34886186
ignore the previous comment , You have to enter it on the line before hostname is specified

ie. vi /etc/rc.sysinit

------Enter it here------
HOSTNAME=`/bin/hostname`

...............

0
 
LVL 23

Expert Comment

by:savone
ID: 34887617
@oppofwar - He needs it to run AFTER the network is up.
0
 
LVL 14

Expert Comment

by:Monis Monther
ID: 34904981
Did you ever try using the full path of the command in your rc.local file??

The PATH variable has not been initialized yet to find your commands under /sbin/ usr/sbin ..etc

Now just to make things clear

1- rc.local is the last file excuted during a boot process and networking comes up much before that. You can examine that by yourself by pressing the letter ( i ) when booting up your machine at the stage where it says welcome to Red Hat Enterpise Linux press i for interactive booting.

2- commands under rc.local must be written using the full path of the command

3- I am not really sure of what the command does but if its something graphical then you need to set display and x-sessino info in the rc.local its not going to popup things for you. Otherwise if its a command that would run in the backgroun then it will be fine.
0
 
LVL 4

Author Comment

by:Alex Matzinger
ID: 34909066
I have tried using the fill path of the command (/usr/bin/synergyc)  and it still does not work.  I am fairly certain that for this program i have to be signed in to allow it to work.  Not the end of the world, just means that i have to continue using two keyboards to log in.

Oh, and synergy is a program that allows a user to use one keyboard and mouse across multiple platforms(such as if you have a windows and linux or Mac machine side by side, you can use one keyboard and mouse to control them all)
0
 
LVL 23

Accepted Solution

by:
savone earned 1200 total points
ID: 34909435
Have you tried what I suggested in adding it to the gnome startup apps?

click System > Preferences > Startup Applications

Then click add and fill in the boxes.  

When you log into gnome it will start the service and the network will already be up.  This worked perfectly for me.
0
 
LVL 4

Author Comment

by:Alex Matzinger
ID: 34909682
I have added it to my gnome start up, so currently once i log in it starts up.  I'm going to leave this question up a little longer just in case before i split the points up.
0
 
LVL 6

Expert Comment

by:de2Zotjes
ID: 34924553
Depending on how strict the security for that box has to be you could setup automated login for it: http://www.linfo.org/automatic_login.html.
That way you no longer need 2 keyboards on your desk :)
0
 
LVL 19

Expert Comment

by:jools
ID: 34978354
Adding to /etc/rc.d/rc.local should be fine, the network is already up at this stage. The docs for synergy seem to require a -f option so you may need something like;

   /path/to/synergyc -f <ipaddress>

However, it may need X to be running for the session to work correctly in which case you need to add to the X startup (mentioned by savone above)

Are there any errors in the log files?
0
 
LVL 4

Author Comment

by:Alex Matzinger
ID: 35012484
-f is just for running the program in the foreground to verify it is working, but is not required.  I haven't found any errors in the log files.  For this program it appears that i'm just going to have to be satisfied with starting it when i log into the machine.
0
 
LVL 10

Expert Comment

by:Martin_J_Parker
ID: 35059125
Yes, X does have to be running to start synergyc
See http://synergy2.sourceforge.net/autostart.html
0
 
LVL 4

Author Closing Comment

by:Alex Matzinger
ID: 35234288
It does not appear that i can get this to run on boot up, so the best solution is to make it start when i log in
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you sitting there reading this and wondering how to get started with Linux? It almost seems like picking the right Linux distribution is about like picking the right college or buying a new car if you read some of the article out there. Relax… l…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question