Solved

Adding a command to run at boot time in RedHat 5

Posted on 2011-02-11
19
1,132 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
  • 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
 
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
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: 34887617
@oppofwar - He needs it to run AFTER the network is up.
0
 
LVL 14

Expert Comment

by:small_student
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 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Users are often faced with high disk consumption without really knowing where the largest amount of data resides. Disk Usage Analyzer (aka Baobab) is is a graphical, menu-driven application to analyse disk usage in any Gnome environment and can e…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now